Note that scales are also packed in their container, just like other tkinter widgets. Let’s
see how these ideas translate in practice; Figure 8-30 shows the window you get if you
run this script live on Windows 7 (you get a similar one on Unix and Mac machines).
Figure 8-30. demoScale in action
For illustration purposes, this window’s State button shows the scales’ current values,
and “Run demo” runs a standard dialog call as before, using the integer value of the
scales to index the demos table. The script also registers a command handler that fires
every time either of the scales is moved and prints their new positions. Here is a set of
messages sent to stdout after a few moves, demo runs (italic), and state requests (bold):
C:\...\PP4E\Gui\Tour> python demoScale.py
['Color', 'Query', 'Input', 'Open', 'Error']
in onMove 0
in onMove 0
in onMove 1
1
in onMove 2
You picked 2
123.0
in onMove 3
3
You picked 3
C:/Users/mark/Stuff/Books/4E/PP4E/dev/Examples/PP4E/Launcher.py
Scales and variables
As you can probably tell, scales offer a variety of ways to process their selections: im-
mediately in move callbacks, or later by fetching current positions with variables or
scale method calls. In fact, tkinter variables aren’t needed to program scales at all—
Checkbutton, Radiobutton, and Scale | 469