Friday, October 17, 2025
HomeLanguageswxPython – GetMenuLabelText() function in wx.MenuBar

wxPython – GetMenuLabelText() function in wx.MenuBar

GetMenuTextLabel() is alternative for GetMenuLabel() function. Just like GetMenuLabel() function GeteMenuTextLabel() function is used to return label of Menu present in Menubar. GetMenuTextLabel() only takes position of menu in the menubar.

Syntax :

wx.MenuBar.GetMenuLabelText(self, menuindex)

Parameters :

Parameter Input Type Description
pos int Position of the menu on the menu bar, starting from zero.

Returns : The menu label, or the empty string if the menu was not found.

Code Example : 

Python3




import wx
 
 
class Example(wx.Frame):
 
    def __init__(self, *args, **kw):
        super(Example, self).__init__(*args, **kw)
 
        # create MenuBar using MenuBar() function
        menubar = wx.MenuBar()
 
        # add menu to MenuBar
        fm1 = wx.Menu()
        fileitem = fm1.Append(20, "one")
        fm2 = wx.Menu()
        fileitem2 = fm2.Append(21, "two")
        menubar.Append(fm1, '&Menu_one')
        menubar.Append(fm2, '&Menu_two')
 
        self.SetMenuBar(menubar)
        self.SetSize((300, 200))
        self.SetTitle('Menu Bar')
 
        # STATIC TEXT WITH LABEL OF MENU AT POSITION 1
        st1 = wx.StaticText(self, label = menubar.GetMenuLabelText(1),
                                                style = wx.ALIGN_LEFT)
 
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
 
 
if __name__ == '__main__':
    main()


Window :

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS