wxPython – SetLabel() function in wx.MenuBar
Last Updated :
27 Mar, 2023
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.SetLabel(self, id, label)
Parameters :
Parameter |
Input Type |
Description |
id |
int |
Menu item identifier. |
label |
string |
Menu item label. |
Code Example :
Python3
import wx
class Example(wx.Frame):
super (w).__init__( * args, * * kwargs)
menubar = wx.MenuBar()
fm1 = wx.Menu()
fileitem = fm1.Append( 20 , "Item
menubar.Append(fm1, '&Menu # 1' )
self .SetMenuBar(menubar)
self .SetSize(( 300 , 200 ))
self .SetTitle( 'Menu Bar' )
menubar.SetLabel( 20 , "New Name")
def main():
app = wx.App()
ex = Example( None )
ex.Show()
app.MainLoop()
if __name__ = = '__main__' :
main()
|
Output :
Share your thoughts in the comments
Please Login to comment...