Skip to content
Related Articles

Related Articles

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

In this article we will learn about FindMenuItem() function prsent in wx.MenuBar class of wxPython. FindMenuItem() is used to return item identifier. FindMenuItem() takes two parameters that is Menu title and submenu item string.

Syntax :

wx.MenuBar.FindMenuItem(self, menuString, itemString)

Parameters :

ParameterInput TypeDescription
menuStringstringMenu title to find.
itemStringstringItem to find.

Return: FindMenuItem() returns the menu item identifier, or wx.NOT_FOUND if none was found.

Code Example:






import wx
  
  
class Example(wx.Frame):
  
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
  
        self.InitUI()
  
    def InitUI(self):
  
        # 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.SetMenuBar(menubar)
        self.SetSize((300, 200))
        self.SetTitle('Menu Bar')
  
        # get id identifier of submenu item
        id = menubar.FindMenuItem("&Menu # 1", "Item # 1")
        print(id)    
  
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
  
  
if __name__ == '__main__':
    main()

Output:

CommandLine Output :

20

 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. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course




My Personal Notes arrow_drop_up
Recommended Articles
Page :