Skip to content
Related Articles

Related Articles

Improve Article

wxPython – SetToolDisabledBitmap() function in wx.ToolBar

  • Last Updated : 04 Jun, 2020

In thia article we are foing to learn about SetToolDisabledBitmap() function associated with the wx.ToolBar class of wxPython. SetToolDisabledBitmap() function sets the bitmap to be used by the tool with the given ID when the tool is in a disabled state. This can only be used on Button tools, not controls. It takes two arguments id and bitmap.


wx.ToolBar.SetToolDisabledBitmap(Self, id, bitmap)


ParameterInput TypeDescription
idintID of the tool in question, as passed to AddTool .
bitmapwx.BitmapBitmap to use for disabled tools.

Code Example 1:

import wx
class Example(wx.Frame):
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
        self.toolbar = self.CreateToolBar()
        td = self.toolbar.AddTool(1, 'right', wx.Bitmap('right.png'))
        # set disabled bitmap for tool wit id = 1
        self.toolbar.SetToolDisabledBitmap(id = 1, bitmap = wx.Bitmap('wrong.png'))
        self.Bind(wx.EVT_TOOL, self.OnOne, td)
        self.SetSize((350, 250))
        self.SetTitle('Undo redo')
    def OnOne(self, e):
        # disable tool
        self.toolbar.EnableTool(toolId = 1, enable = False)
        # Realize() called to finalize new added tools
    def OnQuit(self, e):
def main():
    app = wx.App()
    ex = Example(None)
if __name__ == '__main__':


Before clicking tick tool:

After clicking tick tool:

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :