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)
Parameters:
Parameter Input Type Description colour wx.Colour The 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) self.InitUI() 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('right.png'), 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.toolbar.Realize() self.SetSize((350, 250)) self.SetTitle('Control') self.Centre() def main(): app = wx.App() ex = Example(None) ex.Show() app.MainLoop() if __name__ == '__main__': main() |
Output Window:

Recommended Posts:
- wxPython - Get background colour of Toolbar
- wxPython - Change Background colour of Button
- wxPython - Change Font colour of Radio Button
- wxPython - Change Background Colour of Radio Button
- wxPython - Change Foreground Colour of Button
- wxPython - Change background colour of RadioBox
- wxPython - Change font colour of RadioBox
- wxPython - Change cursor for ToolBar
- wxPython - Dynamically enable and disable tools in toolbar using button
- wxPython - EnableTool() function in wx.Toolbar
- wxPython - AddLabelTool() function in wx.ToolBar
- wxPython - AddControl() method in wx.ToolBar
- wxPython - AddRadioTool() function in wx.ToolBar
- wxPython - AddSeparator() method in wx.ToolBar
- wxPython - RadioGroups in wx.ToolBar
- wxPython | AddStretchableSpace() function in wx.ToolBar
- wxPython - AddTool() function in wx.ToolBar
- wxPython - ClearTools() function in wx.Toolbar
- wxPython - AddSimpleTool() function in wx.ToolBar
- wxPython - DeleteTool() function in wx.ToolBar
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

