Search code examples
pythonuser-interfacecheckboxwxpython

wxPython: How to create a checkbox that has a flat look (bezel-less border).


I am working on a small app that has some checkboxes. The app will be run on Windows 7 machines with the Windows Classic theme set. This means that all the checkboxes will have bezeled borders as shown in the screenshot below:

enter image description here

I wonder if there is a way to set the check boxes to have no bezel. If that is not possible, is it possible to custom paint/draw check boxes with no bezel? I have not been able to find examples. Thanks!


Solution

  • It really depends on the platform and/or the theme, and whether the native widget supports alternate views and such. So, in other words, for questions about customizing the LnF of native widgets in general, the answer is "maybe" but it probably depends on a number of factors that are not under wx's control.

    On the other hand, making custom controls is much easier than most people think it will be. For something like a checkbox you'll basically just need to provide an event handler for EVT_PAINT that draws the current state of the widget using a wx.PaintDC, plus handlers for mouse and keyboard events to interact with the user. There are several examples in the wx.lib package that you can use for inspiration, such as wx.lib.stattext or wx.lib.buttons.