In this article we are going to learn about FindItemById() object in wx.MenuBar class of wxPython. FindItemById() function returns a wx.MenuItem object tuple. It takes only one parameter that is id of menuitem of which wx.MenuItem object we need.
Syntax:
wx.MenuBar.FindItemById(self, id)Parameters :
Parameter Input Type Description id int Menu item identifier. Return Type:
wx.MenuItem
Code Example :
| importwx   classExample(wx.Frame):      def__init__(self, *args, **kwargs):         super(Example, self).__init__(*args, **kwargs)          self.InitUI()      defInitUI(self):         # create MenuBar using MenuBar() function         menubar =wx.MenuBar()         # add menu to MenuBar         fileMenu =wx.Menu()         # add submenu item         fileItem =fileMenu.Append(20, 'SubMenu')         menubar.Append(fileMenu, '&Menu# 1')         self.SetMenuBar(menubar)         self.SetSize((300, 200))         self.SetTitle('Menu Bar')         # get wx.MenuItem object         menuitem =menubar.FindItemById(20)         # print wx.MenuItem object tuple id = 20         print(menuitem)         # print label of menuitem         print(menuitem.GetLabel())            defmain():      app =wx.App()     ex =Example(None)     ex.Show()     app.MainLoop()   if__name__ =='__main__':     main()  | 
Output :
<wx._core.MenuItem object at 0x7fe3009a5288&rt; SubMenu

 
                                    







