Thursday, October 9, 2025
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
32346 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6715 POSTS0 COMMENTS
Nicole Veronica
11878 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11941 POSTS0 COMMENTS
Shaida Kate Naidoo
6837 POSTS0 COMMENTS
Ted Musemwa
7095 POSTS0 COMMENTS
Thapelo Manthata
6790 POSTS0 COMMENTS
Umr Jansen
6791 POSTS0 COMMENTS