simply register movement callbacks or call the scale get method to fetch scale values
on demand, as in the simpler scale example in Example 8-31.
Example 8-31. PP4E\Gui\Tour\demo-scale-simple.py
from tkinter import *
root = Tk()
scl = Scale(root, from_=-100, to=100, tickinterval=50, resolution=10)
scl.pack(expand=YES, fill=Y)
def report():
print(scl.get())
Button(root, text='state', command=report).pack(side=RIGHT)
root.mainloop()
Figure 8-31 shows two instances of this program running on Windows—one stretched
and one not (the scales are packed to grow vertically on resizes). Its scale displays a
range from −100 to 100, uses the resolution option to adjust the current position up
or down by 10 on every move, and sets the tickinterval option to show values next to
the scale in increments of 50. When you press the State button in this script’s window,
it calls the scale’s get method to display the current setting, without variables or call-
backs of any kind:
C:\...\PP4E\Gui\Tour> python demo-scale-simple.py
0
60
-70
Figure 8-31. A simple scale without variables
Frankly, the only reason tkinter variables are used in the demoScale script at all is to
synchronize scales. To make the demo interesting, this script associates the same tkinter
470 | Chapter 8: A tkinter Tour, Part 1