Web Analytics Made Easy - Statcounter
Skip to content

Custom Checkboxes

A common complaint I've heard from Python programmers are how dated the GUI look. With PySimpleGUI this is a problem that's easy to overcome. It's trivial in fact.

In this very short example, you'll see how making checkboxes look any way you want them to look by using Base64 encoded PNG images. There is a PySimpleGUI utility that makes the job even easier! pip install psgresizerto get the psgresizer tool that I used to create these checkboxes. This tool will encode an image into a Base64 encoded bytestring that is placed on the clipboard, ready for you to paste into your code. It will take you under 5 minutes, if that, to have checkboxes of any style you want.

psgresizer

This is a screenshot of the psgresizer tool that you can pip install and run from the command line.

snag-1678.jpg

The program is quite small that demonstrates the custom checkboxes. Instead of specifying a Checkbox element as you would normally, you use an Image element. Setting the enable_events parameter will cause an event to be generated when the user clicks the checkbox. You can then change the image shown in your event loop when you detect the checkbox has been clicked.

This is how this Custom Checkbox program appears when running on Windows.

checkboxes.gif