Saturday, January 17, 2026
HomeLanguageswxPython – SetToolNormalBitmap() function in wx.ToolBar

wxPython – SetToolNormalBitmap() function in wx.ToolBar

In this article we are going to learn about SetToolNormalBitmap() function associated with the wx.ToolBar class of wxPython. SetToolNormalBitmap() is used to set the bitmap to be used by the tool with the given ID. This can only be used on Button tools, not controls. It takes two parameters that are id and bitmap.

Syntax:

wx.ToolBar.SetToolNormalBitmap(self, id, bitmap)

Parameters:

Parameter Input Type Description
id int ID of the tool in question, as passed to AddTool .
bitmap wx.Bitmap Bitmap to use for normals tools.

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.toolbar = self.CreateToolBar()
 
        td = self.toolbar.AddTool(1, 'right', wx.Bitmap('right.png'))
        # set disabled bitmap for tool with id = 1
        self.toolbar.Realize()
        self.Bind(wx.EVT_TOOL, self.OnOne, td)
 
        self.SetSize((350, 250))
        self.SetTitle('Undo redo')
        self.Centre()
 
    def OnOne(self, e):
        # set new bitmap of tool with id = 1
        self.toolbar.SetToolNormalBitmap(id = 1, bitmap = wx.Bitmap('wrong.png'))
        # Realize() called to finalize new added tools
        self.toolbar.Realize()
 
    def OnQuit(self, e):
        self.Close()
 
 
def main():
 
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
 
 
if __name__ == '__main__':
    main()


Output: Before clicking tool: After clicking tool:

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