Search code examples
pythonuser-interfacewxpython

Python - Custom styling in wxPython


Is there some way I can create custom styles in wxPython? I searched all the docs and websites referring to wxPython styling and could find nothing. Do I have to create the custom style using the wxPython canvas?


Solution

  • wxPython uses native widgets in its core widgets as much as possible. Most of the widgets are going to be "native" to the system you are using, so unfortunately you can't fully manipulate how the control paints itself.

    Sometimes, you can modify widgets via the methods mentioned in the documentation, such as using SetBackgroundColour() or SetForegroundColour(). Depending on your OS's widget, they may or may not work.

    The other option is to use the wx.PaintDC, wx.ClientDC, wx.WindowDC, wx.ScreenDC and/or wx.MemoryDC to draw custom widgets directly.