Home Software Hardware Misc About

AClock

vs. 0.5 (2021)

The AnalogClock shipped with wxPython is pretty neat. It is lightweight and highly customizable. I wrote most of it some fifteen years ago, improving the code of the old wxPython Demos's analog clock, which in turn was written by several wxPython users.

Its features include the ability to use numbers as well as any arbitrary polygon as tick marks, render shadows on hands and tick marks, resize marks and hands proportionally as the widget itself is resized, rotate marks in a way the get aligned to the watch, change all of its components colours, and so on. It also has a setup dialog accessed via a context menu item so that you can change on the fly all of its settings.

But now I wanted to have some fun coding a simpler clock to run on the Raspberry Pi I got in my room to be shown along an information display. I wanted it simpler than AnalogClock, still lightweight (and maybe even more). And with a transparent background, so that I could use a nice background image.

This clock, simply named "AClock", can be easily imported and used in other programs. The code is pretty simple, but it has got some tricks to keep it light (also see the code to check how to derive a GCDC that draws rotated polygons, if you're not into affine transformations).

Click here to download the file containing the library itself. Save it somewhere and test it, running from a terminal where you saved using

python3 aclock.py

Tested on wxPython 4.1.0 (gtk3) on Python 3.7.3 on Raspberry Pi OS. Distributed under the BSD-3-Clause License.