Skip to content
Related Articles

Related Articles

Improve Article

wxPython – GetLabelText() function in wxPython

  • Last Updated : 09 Jun, 2020

In this article we are going to learn about GetLabelText() function associated with wx.MenuItem class of wxPython. GetLabelText() function strips all accelerator characters and mnemonics from the given text.
For Example:
will return just “Hello” .

Takes sing unstriped text as a parameter.




type: string
description: unstriped text to get striped text.

Return Type:


Code Example:

import wx
class Example(wx.Frame):
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
        self.menubar = wx.MenuBar()
        self.fileMenu = wx.Menu() = wx.StaticText(self, label ="", pos =(20, 20), style = wx.ALIGN_LEFT)
        self.item = wx.MenuItem(self.fileMenu, 1, '&Check\tCtrl + c', helpString ="Check Help")
        self.menubar.Append(self.fileMenu, '&File')
        # label text from item
        label = self.item.GetLabelText('&Check\tCtrl + c')
        # print kind of menuitem
        self.SetSize((350, 250))
        self.SetTitle('Icons and shortcuts')
def main():
    app = wx.App()
    ex = Example(None)
if __name__ == '__main__':



Output Window:

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :