Summary
At OSCON I rewrote one of the earliest Python graphics demos I ever did, this time in Tkinter -- a colorful clock. Miguel de Icaza thinks it's cool!
Advertisement
Some time in the '80s I saw a very cool wall clock. It has two transparent discs attached to the hands, where each disc has nine gradations of a primary color applied to it. The background has a similar, fixed pattern using the third primary color. The result is a clock that looks different every minute! Hard to describe properly; you have to see it. (And you will, hold on.)
My parents bought me that clock as a birthday present. The front says "M Clock" and "Rob Juda". (I've seen other, similar clocks by the same designer.) After having moved half a dozen times, it's still hanging on my kitchen wall telling the time and getting curious looks from visitors.
In the early '90s I did a software implementation of that clock in Python, using the SGI GL bindings that we had just created at CWI. It made it into the Python distribution as a demo, but was eventually withdrawn because GL support died and I didn't have the time to port it to OpenGL. (It's still in the
CVS Attic.)
A few weeks I received an email from the designer, Mr. Juda (a compatriot of mine), asking if the software was still available. There is a clock museum in the Netherlands (Schoonhoven) which has all of Mr. Juda's designs on display, and he thought that the museum would be interested in the software version, if it was still available (and ran on Windows). He told me some of the history of the clock -- about 100,000 clocks were produced and sold from '84 through '94. It was hard to sell the clock because people wouldn't realize that three totally different looking clocks were really the same clock at different times!
I promised Mr. Juda that I would consider reviving the software, and here it is:
mclock2.py. It runs on Windows and Unix as long as you have a recent version of Python with Tkinter enabled. (The most recent Windows installer of Python is downloadable from python.org/2.4.1/.) Tip for Windows users: rename the file to "mclock2.pyw" to suppress the text console.
PS: It would be cool if someone did an Xscreensaver version of this...
PPSS: The first version I posted had the color gradations reversed. I've fixed that, made the hands look more like those on the original, and removed the right-click-to-zoom feature on Unix (it was using a Tk feature that only works on Windows). URL is unchanged.
Not an Xscreensaver version, but one where all 3 discs move, and the pattern changes significantly every second. The old fixed disc now moves with the hour hand, the hour disc now moves with the minute hand, and the minute disc moves with the new second hand.
Excellent clocks. Increasing the segment count from 9 to 60 is a significant step away from the original design but smooths the colours out in a nice way.
A minor nitpick re the draw method in the source code: conversions between radians and degrees are available in the math module (functions have the same names as their target). Batteries included ;-)
> A minor nitpick re the draw method in the source code: > conversions between radians and degrees are available in > the math module (functions have the same names as their > target). Batteries included ;-)
Ow, thanks. They didn't exist when I first created the math module 15 years ago. :-) Fixed now.
My PC has now a variant of this clock that starts with the PC. I've just spent twenty minutes trying to find out why my spreadsheet was running so slowly.
So guess what was hogging the CPU? Turning it off speeded my app from <1 to 70+ rows/sec update. Mind you, my version of this clock has the second hand and 360 colour segments, so I've only myself to blame. :)
If you get really good with your colors, then you don't really need the hands on the clock. The colors will tell you what time it is! That will take me a while to get used to, though; I have trouble with military (24-hour) time...