Version 9 of radiobutton

Updated 2004-05-22 19:38:23

http://purl.org/tcl/home/man/tcl8.4/TkCmd/radiobutton.htm


Example:

Radio buttons are linked using a common variable, which will have the value of the selected button.

 package require Tk

 set ::onetwothree "3"

 pack [radiobutton .one   -value 1 -text "One"   -variable onetwothree -command { puts $::onetwothree }]
 pack [radiobutton .two   -value 2 -text "Two"   -variable onetwothree -command { puts $::onetwothree }]
 pack [radiobutton .three -value 3 -text "Three" -variable onetwothree -command { puts $::onetwothree }]

The results will be that, on stdout, the number of the radiobutton pressed is output.

Also note that by setting the variable to 3, the 3rd radio button is selected at the beginning of the code.


rdt As an example, this is (of course) correct code, but in this case is there ever a time which you would not want to have the "-anchor w" argument to the pack command to align the buttons?


See the vertical command, which allows to place the text below the checkfield, on the checkbutton page.


See also

  • Lightbutton a pure Tcl package mimicking the radio and the checkbuttons, with bright and pretty colors.

Category Widget - Category Command - Tk syntax help - Arts and Crafts of Tcl-Tk Programming