Thursday, January 22, 2026
HomeLanguageswxPython – FindMenuItem() function in wx.MenuBar

wxPython – FindMenuItem() function in wx.MenuBar

In this article we will learn about FindMenuItem() function present 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 : 

 

Parameter Input Type Description
menuString string Menu title to find.
itemString string Item to find.

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

Code Example: 
 

Python3




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

 

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32475 POSTS0 COMMENTS
Milvus
119 POSTS0 COMMENTS
Nango Kala
6847 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12064 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7220 POSTS0 COMMENTS
Thapelo Manthata
6933 POSTS0 COMMENTS
Umr Jansen
6912 POSTS0 COMMENTS