Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

wxPython – Add Sub-Menu in menubar

  • Last Updated : 29 Oct, 2021

In this article we will learn how can we add submenu item to menu item present on menubar. We can do this by same Append() function present in wxMenuBar class.

Syntax: wx.MenuBar.Append(self, menu, title)


ParameterInput TypeDescription
menuwx.MenuThe menu to add. Do not deallocate this menu after calling Append .
titlestringThe title of the menu, must be non-empty.

Return: bool 

Code Example: 


import wx
class Example(wx.Frame):
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
    def InitUI(self):
        # create MenuBar using MenuBar() function
        menubar = wx.MenuBar()
        # add menu to MenuBar
        fileMenu = wx.Menu()
        # add submenu item
        fileItem = fileMenu.Append(20, 'SubMenu')
        menubar.Append(fileMenu, '&Menu# 1')
        self.SetSize((300, 200))
        self.SetTitle('Menu Bar')
def main():
    app = wx.App()
    ex = Example(None)
if __name__ == '__main__':

Output :


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!