Skip to content
Related Articles

Related Articles

wxPython – change toolbar colour wx.ToolBar

View Discussion
Improve Article
Save Article
  • Last Updated : 26 Jun, 2020

In this article we are going to learn to change the colour of toolbar. We will simply use SetBackgroundColour() function in order to do this. SetBackgroundColour() dimply sets the background colour of the window. Itakes a wx.Colour parameter, i.e., the colour to be used as the background colour.

Syntax: wx.ToolBar.SetBackgroundColour(self, colour)


ParameterInput TypeDescription
colourwx.ColourThe colour to be used as the background colour

Return Type: bool

Returns: True if the colour was really changed, False if it was already set to this colour and nothing was done.

Code Example:

import wx
class Example(wx.Frame):
    global count
    count = 0;
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
        pnl = wx.Panel(self)
        self.toolbar = self.CreateToolBar()
        # Add tools to toolbar
        ptool = self.toolbar.AddTool(12, 'oneTool',
                                     wx.Bitmap('wrong.png'), shortHelp ="Simple Tool")
        qtool = self.toolbar.AddTool(12, 'oneTool', wx.Bitmap('wrong.png'),
                                     wx.Bitmap('wrong.png'), shortHelp ="Simple Tool")
        # change background colour of toolbar
        self.toolbar.SetBackgroundColour((255, 200, 50, 255))
        self.SetSize((350, 250))
def main():
    app = wx.App()
    ex = Example(None)
if __name__ == '__main__':

Output Window:

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!