Python – FindItem() function in wx.MenuBar
Last Updated :
10 May, 2020
In this article we will learn about FindItem function present in wx.MenuBar class of wxPython. FindItem() only takes one parameter that is item identifier. FindItem() finds the menu item object associated with the given menu item identifier.
Syntax :
wx.MenuBar.FindItem(self, id)
Parameters :
Parameter |
Input Type |
Description |
id |
int |
Menu item identifier. |
Example:
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()
fileItem = fileMenu.Append( 20 , 'SubMenu' )
menubar.Append(fileMenu, '&Menu# 1' )
self .SetMenuBar(menubar)
self .SetSize(( 300 , 200 ))
self .SetTitle( 'Menu Bar' )
print (menubar.FindItem( 20 ))
def main():
app = wx.App()
ex = Example( None )
ex.Show()
app.MainLoop()
if __name__ = = '__main__' :
main()
|
Output :
(<wx._core.MenuItem object at 0x7fd6797401f8&rt;, <wx._core.Menu object at 0x7fd67973d828&rt;)
Share your thoughts in the comments
Please Login to comment...