This section introduces three widget types -- the
Checkbutton (a multiple-choice input widget), the
Radionbutton (a single-choice device), and the
Scale (sometimes known as a “slider”).
All are variations on a theme, and somewhat related to simple
buttons, so we’ll explore them as a group here. To make these
widgets more fun to play with, we’ll reuse the
dialogTable module shown in Example 7-8 to provide callbacks for widget selections
(callbacks pop up dialog boxes). Along the way, we’ll also use
the Tkinter variables we just met to communicate with these
widgets’ state settings.
widgets are designed to be associated with Tkinter variables: pushing
the button changes the value of the variable, and setting the
variable changes the state of the button it is linked to. In fact,
Tkinter variables are central to the operation of these widgets:
A collection of checkbuttons implements a multiple-choice interface, by assigning each button a variable of its own.
A collection of radiobuttons imposes a mutually exclusive single-choice model, by giving each button a unique value and the same Tkinter variable.
Both kinds of buttons provide both
variable options. The
option lets you register a callback to be run immediately on
button-press events, much like normal
widgets. But by associating a Tkinter variable with the
variable option, you can also fetch or change widget state at any ...