To minimize screen updates, PyClock redraws only clock hands on second rollovers;
points on the clock’s circle are redrawn only at startup and on window resizes. Fig-
ure 11-20 shows the default initial PyClock display format you get when the file
clock.py is run directly.
Figure 11-20. PyClock default analog display
The clock hand lines are given arrows at their endpoints with the canvas line object’s
arrow and arrowshape options. The arrow option can be first, last, none, or both; the
arrowshape option takes a tuple giving the length of the arrow touching the line, its
overall length, and its width.
Like PyView, PyClock also uses the widget pack_forget and pack methods to dynami-
cally erase and redraw portions of the display on demand (i.e., in response to bound
events). Clicking on the clock with a left mouse button changes its display to digital by
erasing the analog widgets and drawing the digital interface; you get the simpler display
captured in Figure 11-21.
Figure 11-21. PyClock goes digital
This digital display form is useful if you want to conserve real estate on your computer
screen and minimize PyClock CPU utilization (it incurs very little screen update over-
head). Left-clicking on the clock again changes back to the analog display. The analog
752 | Chapter 11: Complete GUI Programs