Python GetMenu() function in wxPython (original) (raw)
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 :
Parameter Input Type Description menuindex int The position of the menu in the menu bar Returns : Returns the menu at menuIndex (zero-based).
Code Example :
Python3 `
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.SetMenuBar(menubar)
self.SetSize((300, 200))
self.SetTitle('Menu Bar')
# print returned menu object
print(menubar.GetMenu(1))
def main(): app = wx.App() ex = Example(None) ex.Show() app.MainLoop()
if name == 'main': main()
`
Output Command Line Output :
<wx._core.Menu object at 0x7fa64ba65318>
Similar Reads
- wxPython | GetMargins() function in python In this article we are going to learn about GetMargins() function of class wx.ToolBar in wxPython. GetMargins() function returns the left/right and top/bottom margins, which are also used for inter-toolspacing. GetMargins takes no parameters. Syntax: wx.ToolBar.GetMargins(self) Parameters: No Parame 2 min read
- wxPython | GetToolEnabled() function in python In this article we are going to learn about GetToolEnabled() function present in class wx.ToolBar of wxPython. GetToolEnabled() function simply returns a pointer to the tool at particular position. It takes only single argument that is pos(position of tool starting from 0). Syntax : wx.ToolBar.GetTo 2 min read
- wxPython | GetToolPos() function in python In this article we are going to learn about GetToolPos() function associated with wx.ToolBar class of wxPython. GetToolPos() function simply returns the tool position in the toolbar, or NOT_FOUND if the tool is not found. GetToolPos() function only takes toolId(ID of the tool in question, as passed 2 min read
- wxPython - GetLabelText() function in wxPython In this article we are going to learn about GetLabelText() function associated with wx.MenuItem class of wxPython. GetLabelText() function strips all accelerator characters and mnemonics from the given text. For Example: wx.MenuItem.GetLabelfromText("&Hello\tCtrl-h") will return just "Hello" . T 1 min read
- wxPython | GetToolPacking() function in python In this article we are going to learn about GetToolPacking() function associated with wx.ToolBar class of wxPython. GetToolPacking() function simply returns the value used for packing tools.The packing is used for spacing in the vertical direction if the toolbar is horizontal, and for spacing in the 2 min read
- wxPython | GetToolByPos() function in python In this article we are going to learn about GetToolByPos() function present in wx.ToolBar class of wxPython. GetToolByPos() function is used to simply return a pointer to the tool at specific position. GetToolByPos() function takes a single parameter that is pos(position of tool). Syntax: wx.ToolBar 2 min read
- wxPython | GetToolBitmapSize() function in python In this article we are going to learn about GetToolBitmapSize() function of wxPython. GetToolBitmapSize() returns the size of bitmap that a toolbar expects to have. The default bitmap size is platform-dependent: for example, it is 16x15 for MSW and 24x24 for GTK. This size does not necessarily indic 2 min read
- Python - Move() function in wxPython In this particular article we will learn, how can we move our window to a particular point. This can be achieved using Move() function in wx.Window class of wxPython. Move() takes x and y points to move window to a particularx, y point. Syntax : wx.Move(self, x, y, flags=SIZE_USE_EXISTING) Parameter 1 min read
- 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 - GetMenus() function in wx.MenuBar In this article we are going to learn about GetMenus() function associated with wx.MenuBar class of wxPython. GetMenus() function simply returns a list of (menu, label) items for the menus in the MenuBar. No arguments are required in GetMenus() function. Syntax: wx.MenuBar.GetMenus(self) Parameters: 1 min read