wxPython - GetSubMenu() function in wx.MenuItem Last Updated : 03 Mar, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article we are going to learn about GetSubMenu() function associated with the class wx.MenuItem in wxPython. GetSubMenu() function returns the submenu associated with the menu item, or None if there isn’t one. No arguments are needed in GetSubMenu() function. Syntax: wx.MenuItem.GetSubMenu(self) Parameters: No parameters are needed in GetSubMenu() function. Return Type: wx.Menu 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): menubar = wx.MenuBar() fileMenu = wx.Menu() sm = wx.Menu() sm.Append(wx.ID_ANY, 'Submenu item 1') sm.Append(wx.ID_ANY, 'Submenu item 2') sm.Append(wx.ID_ANY, 'Submenu item 3') self.st = wx.StaticText(self, label ="", pos =(20, 20), style = wx.ALIGN_LEFT) item = wx.MenuItem(fileMenu, 1, '&Check\tCtrl + c', helpString ="Check Help") item.SetSubMenu(sm) fileMenu.AppendMenu(wx.ID_ANY, 'I&mport', sm) # get submenu s = item.GetSubMenu() # get total sub menu item n = s.MenuItemCount # print total sub menu item print(n) self.st.SetLabel(str(n)+" total submenu items") menubar.Append(fileMenu, '&File') self.SetMenuBar(menubar) self.SetSize((350, 250)) self.SetTitle('Submenu') self.Centre() def main(): app = wx.App() ex = Example(None) ex.Show() app.MainLoop() if __name__ == '__main__': main() Output: 3 Output: Comment More infoAdvertise with us Next Article wxPython - GetSubMenu() function in wx.MenuItem R RahulSabharwal Follow Improve Article Tags : Python Python-gui Python-wxPython Practice Tags : python Similar Reads wxPython - GetMenu() function in wx.MenuItem In this article we are going to learn about GetMenu() function associated with wx.MenuItem class of wxPython. GetMenu() function returns the menu this menu item is in, or None if this menu item is not attached. No arguments are needed in GetMenu() function. Syntax: wx.MenuItem.GetMenu(self) Paramete 1 min read wxPython - GetId() function in wx.MenuItem In this article we are going to learn about GetId() function associated with wx.MenuItem class of wxPython. As the name suggests GetId() function returns the menu item identifier of int type.No parameters are required in GetId() function. Syntax: wx.MenuItem.GetId() Parameters: No parameters are req 1 min read wxPython - GetKind() function in wx.MenuItem In this article we are going to learn about GetKind() function associated with the wx.MenuItem class of wxPython. GetKind function simply returns the item kind, one of ITEM_SEPARATOR, ITEM_NORMAL, ITEM_CHECK or ITEM_RADIO. It takes no parameters. Syntax: wx.GetKind(self) Parameters: No parameters ar 2 min read wxPython - GetHelp() function in wx.MenuItem In this article we are going to learn about GetHelp() function associated with the wx.MenuItem class of wxPython. GetHelp() function simply returns the help string associated with the menu item. No parameters are required in GetHelp() function. Syntax: wx.GetHelp(self) Parameters: No parameters are 1 min read wxPython - GetFont() function in wx.MenuItem In this article we are going to learn about GetFont() function associated with the wx.MenuItem class of wxPython. GetFont() function is used to simply return the font associated with the menu item. No parameters are required in GetFont() function. Syntax: wx.MenuItem.GetFont(self) Parameters: no par 1 min read Like