Related Articles

Related Articles

wxPython – GetMenuLabel() function in wx.MenuBar
  • Last Updated : 11 May, 2020

GetMenuLabel() function is another function present in wx.MenuBar class of wxPython. GeteMenuLabel() function is used to return label of Menu present in Menubar. GetMenuLabel() only takes position of menu in the menubar.

Syntax :

wx.MenuBar.GetMenuLabel(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 :



filter_none

edit
close

play_arrow

link
brightness_4
code

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 POSITIO 1
        st1 = wx.StaticText(self, label = menubar.GetMenuLabel(1), 
                                            style = wx.ALIGN_LEFT)
  
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
  
  
if __name__ == '__main__':
    main()

chevron_right


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.




My Personal Notes arrow_drop_up
Recommended Articles
Page :