Friday, November 21, 2025
HomeLanguageswxPython – IsEnabled() function in wx.MenuBar

wxPython – IsEnabled() function in wx.MenuBar

In this article we are going to learn about IsEnabled() function associated with wx.MenuBar class of wxPython. IsEnabled() function is useful as it determines whether an item is enabled. IsEnabled() function returns True if the item was found and is enabled, False otherwise.

Syntax: wx.MenuBar.IsEnabled(self, id)

Parameters:

Parameter Input Type Description
id int The menu item identifier.

Code Example:




import wx
  
  
class Example(wx.Frame):
  
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
  
        self.InitUI()
  
    def InitUI(self):
  
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
        self.menubar = wx.MenuBar()
        self.fileMenu = wx.Menu()
        self.fileMenu2 = wx.Menu()
        self.item = wx.MenuItem(self.fileMenu, 1, '&Check', helpString ="Check Help"
                                                              kind = wx.ITEM_CHECK)
        self.item.SetBitmap(wx.Bitmap('right.png'))
        self.fileMenu.Append(self.item)
  
        # DISABLE MENU ITEM
        self.item.Enable(False)
        self.menubar.Append(self.fileMenu, '&File')
        self.SetMenuBar(self.menubar)
        self.SetSize((350, 250))
        self.SetTitle('New Frame Title')
        self.Centre()
        if(self.menubar.IsEnabled(1)== True):
            # print CLICKABLE if True
            print("CLICKABLE")
        else:
            # else print UNCLICKABLE
            print("UNCLICKABLE")
  
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
  
  
if __name__ == '__main__':
    main()


Output:

Console Output:

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

Most Popular

Dominic
32405 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6781 POSTS0 COMMENTS
Nicole Veronica
11928 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11995 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7166 POSTS0 COMMENTS
Thapelo Manthata
6862 POSTS0 COMMENTS
Umr Jansen
6847 POSTS0 COMMENTS