Skip to content
Related Articles

Related Articles

wxPython – SetLabel() function in wx.MenuBar

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 11 May, 2020

Another important function in wx.MenuBar is SetLabel() function in wx.MenuBar class of wxPython. SetLabel() function is used to change the Label(title) of the menu item in menubar. It is used only after the menubar has been associated with a frame.

Syntax :

wx.MenuBar(self, id, label)

Parameters :

ParameterInput TypeDescription
idintMenu item identifier.
labelstringMenu item label.

Code Example :

import wx
class Example(wx.Frame):
        super(w).__init__(*args, **kwargs)
        # create MenuBar using MenuBar() function
        menubar = wx.MenuBar()
        # add menu to MenuBar
        fm1 = wx.Menu()
        fileitem = fm1.Append(20, "Item # 1")
        menubar.Append(fm1, '&Menu # 1')
        self.SetSize((300, 200))
        self.SetTitle('Menu Bar')  
        # change label of menu item to New Name
        menubar.SetLabel(20, "New Name")
def main():
    app = wx.App()
    ex = Example(None)
if __name__ == '__main__':

Output :

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!