In this article we will learn about EnableTop() function of wx.MenuBar class of wxPython. The only difference b/w Enable() and EnableTop() is that EnableTop() is used to make the whole Menu in Menu Bar unclickable or clickable.
Syntax:
wx.MenuBar.EnableTop(self, id, enable)Parameters :
Parameter Input Type Description pos int The position of the menu, starting from zero. enable bool True to enable the menu, False to disable it.
Code Example:
import wx class Example(wx.Frame): def __init__( self , * args, * * kwargs): super (Example, self ).__init__( * args, * * kwargs) self .InitUI() def InitUI( self ): # create MenuBar using MenuBar() function menubar = wx.MenuBar() # add menu to Menuitem fileMenu = wx.Menu() fileMenu2 = wx.Menu() fileMenu3 = wx.Menu() menubar.Append(fileMenu, '&Menu# 1' ) menubar.Append(fileMenu2, '&Menu# 2' ) menubar.Append(fileMenu3, '&Menu# 3' ) self .SetMenuBar(menubar) self .SetSize(( 300 , 200 )) self .SetTitle( 'Menu Bar' ) # Disable Menu# 2 in menu bar menubar.EnableTop( 1 , False ) def main(): app = wx.App() ex = Example( None ) ex.Show() app.MainLoop() if __name__ = = '__main__' : main() |