if name == 'main':
Width = 500 # default width, height
if len(sys.argv) == 2: Width = int(sys.argv[1]) # width cmdline arg?
originX = originY = Width // 2 # same as circle radius
makewidgets() # on default Tk root
mainloop() # need 3.x // trunc div
The circle defaults to 500 pixels wide unless you pass a width on the command line.
Given a number of points on a circle, this script marks out the circle in clockwise order
every time you press Plot, by drawing lines out from the center to small rectangles at
points on the circle’s shape. Move the slider to plot a different number of points and
click the checkbox to make the drawing happen slow enough to notice the clockwise
order in which lines and points are drawn (this forces the script to update the display
after each line is drawn). Figure 11-19 shows the result for plotting 120 points with the
circle width set to 400 on the command line; if you ask for 60 and 12 points on the
circle, the relationship to clock faces and hands starts becoming clearer.
Figure 11-19. plotterGui in action
PyClock: An Analog/Digital Clock Widget | 749