Node:checkbutton, Next:, Previous:button, Up:Widget Creation


Checkbuttons are buttons that have a fixed state that is either on or off. Clicking on the button toggles the state. To store the state, a checkbutton is associated with a variable. When the state of the checkbutton changes, so does that of the variable. An example is:

checkbutton .on_or_off -text "I like ice cream" -variable ice

which will create a checkbutton with name .on_or_off displaying the text I like ice cream and associated with the variable ice. If the checkbutton is checked then ice will have the value 1; if not checked then it will have the value 0. The state of the checkbutton can also be changed by changing the state of the variable. For example, executing

set ice 0

will set the state of .on_or_off to not checked.