Previous: Data entry example
Up: Widgets
Next: Using check buttons
Previous Page: Data entry example
Next Page: Using check buttons

Using radio buttons

In the application developed here, the entry for sex has not been carried out according to our original specification, which suggested that a radiobutton be used.

The following is a possible implementation of a pair of radio buttons which will achieve the desired effect:

radiobutton .male -width 10 -text "Male"  -variable sex -value "Male"
radiobutton .female -width 10 -text "Female" -variable sex -value "Female"

Since both radio buttons are bound to the same variable, sex, the mutual exclusivity is determined by the system. Note that initially neither button is set, so strict mutual exclusivity only applies once one of the buttons has been selected. If an initial setting is required, this can be handled by the use of an appropriate set command, such as

set sex Female

Clearly these radio buttons will need to be packed into the application appropriately.

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