Tuesday, June 9, 2026
HomeLanguagesPython – FindMenu() functionin wx.MenuBar

Python – FindMenu() functionin wx.MenuBar

In this article we are going to learn about FindMenu() function in wx.MenuBar class of wxPython. FindMenu() function returns the index/position of the menu item. FindMenu() function takes only one argument that is name of menu item.

Syntax :

wx.MenuBar.FindMenu(self, title)

Parameter:

Parameter Input Type Description
title string title of menuitem.

Return Type :

int

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()
  
        # menu for menuitem
        fm1 = wx.Menu()
        fm2 = wx.Menu()
        fm3 = wx.Menu()
  
        menubar.Append(fm1, '&Menu# 1')
        menubar.Append(fm2, '&Menu# 2')
        menubar.Append(fm3, '&Menu# 3')
  
        self.SetMenuBar(menubar)
        self.SetSize((300, 200))
        self.SetTitle('Menu Bar')
  
        # get index of menuitem using FindMenu function
        index = menubar.FindMenu("&Menu# 3")
        print(index)    
  
def main():
  
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
  
  
if __name__ == '__main__':
    main()


Output :
1. Window output:

2. print output

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

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6895 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7018 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS