Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Python – GetMenu() function in wxPython

  • Last Updated : 15 May, 2020

In this particular article we are going to learn about GetMenu() function of wx.MenuBar class of wxPython. GetMenu() is function in wx.MenuBar class that return wx.Menu object present in Menubar. It needs only index of menu present on menubar.

Syntax :

wx.MenuBar.GetMenu(self, menuindex)

Parameters :

ParameterInput TypeDescription
menuindexintThe position of the menu in the menu bar

Returns : Returns the menu at menuIndex (zero-based).

Code Example :

import wx
class Example(wx.Frame):
    def __init__(self, *args, **kw):
        super(Example, self).__init__(*args, **kw)
        # create MenuBar using MenuBar() function
        menubar = wx.MenuBar()
        # add menu to MenuBar
        fm1 = wx.Menu()
        fileitem = fm1.Append(20, "one")
        fm2 = wx.Menu()
        fileitem2 = fm2.Append(21, "two")
        menubar.Append(fm1, '&Menu_one')
        menubar.Append(fm2, '&Menu_two')
        self.SetSize((300, 200))
        self.SetTitle('Menu Bar')
        # print returned menu object
def main():
    app = wx.App()
    ex = Example(None)
if __name__ == '__main__':


Command Line Output :

<wx._core.Menu object at 0x7fa64ba65318>

 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 :

Start Your Coding Journey Now!