Previous: Using radio buttons
Up: Widgets
Next: Modifying the application to display pre-stored data
Previous Page: Using radio buttons
Next Page: Modifying the application to display pre-stored data

Using check buttons

With a little more ingenuity, it is possible to use a single check button to allow the value for the variable sex to be set.

#set gender "Female"  - initialisation - if needed
checkbutton .sex1 -width 15 -textvariable "gender" -variable sex  
   -onvalue Male -offvalue Female  
   -command {set gender $sex}

When the checkbutton is set on, the value of the variable sex is set to Male, and when the button is off, the value is set to Female.Ó

Some politically correct readers may prefer to have the onvalues and offvalues of this checkbutton swapped over!

csstddm@brunel.ac.uk
Fri Aug 19 16:55:19 BST 1994