Saturday, January 17, 2026
HomeLanguagesPython – EnableTop() function in wx.MenuBar

Python – EnableTop() function in wx.MenuBar

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()


Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32474 POSTS0 COMMENTS
Milvus
118 POSTS0 COMMENTS
Nango Kala
6846 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12063 POSTS0 COMMENTS
Shaida Kate Naidoo
6985 POSTS0 COMMENTS
Ted Musemwa
7219 POSTS0 COMMENTS
Thapelo Manthata
6933 POSTS0 COMMENTS
Umr Jansen
6911 POSTS0 COMMENTS