Wednesday, July 3, 2024
HomeLanguagesPythonwxPython – SetDisabledBitmap() function in wx.MenuItem

wxPython – SetDisabledBitmap() function in wx.MenuItem

In this article we are going to learn about SetDisabledBitmap() function associated to wx.MenuItem class of wxPython. SetDisabledBitmap() function is used to simply set the bitmap to be used for disabled menu items. It take single bitmap parameters for disabled item.

Syntax:

wx.MenuItem.SetDisabledBitmap(self, disabled)

Parameters:

Parameter Input Type Description
disabled wx.Bitmap Bitmap to set for disabled menu item.

Code Example: 

Python3




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.item = wx.MenuItem(self.fileMenu, 1, '&Radio', helpString ="Check Help", kind = wx.ITEM_CHECK)
        self.item.SetBitmap(bmp = wx.Bitmap('right.png'))
        # set bitmap for menuitem while disabled
        self.item.SetDisabledBitmap(wx.Bitmap('wrong.png'))
        self.item.Enable(False)
        self.fileMenu.Append(self.item)
        self.menubar.Append(self.fileMenu, '&File')
        self.SetMenuBar(self.menubar)
        self.SetSize((350, 250))
        self.SetTitle('Icons and shortcuts')
        self.Centre()
 
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
 
 
if __name__ == '__main__':
    main()


Output:

Nicole Veronica Rubhabha
Nicole Veronica Rubhabha
A highly competent and organized individual DotNet developer with a track record of architecting and developing web client-server applications. Recognized as a personable, dedicated performer who demonstrates innovation, communication, and teamwork to ensure quality and timely project completion. Expertise in C#, ASP.Net, MVC, LINQ, EF 6, Web Services, SQL Server, MySql, Web development,
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments