3 # This demonstration script creates a toplevel window containing
4 # several radiobutton widgets.
6 # RCS: @(#) $Id: radio.tcl,v 1.8 2007/04/23 21:16:01 das Exp $
8 if {![info exists widgetDemo
]} {
9 error "This script should be run from the \"widget\" demo."
17 wm title
$w "Radiobutton Demonstration"
18 wm iconname
$w "radio"
20 label $w.msg
-font $font -wraplength 5i
-justify left
-text "Three groups of radiobuttons are displayed below. If you click on a button then the button will become selected exclusively among all the buttons in its group. A Tcl variable is associated with each group to indicate which of the group's buttons is selected. When the 'Tristate' button is pressed, the radio buttons will display the tri-state mode. Selecting any radio button will return the buttons to their respective on/off state. Click the \"See Variables\" button to see the current values of the variables."
21 grid $w.msg
-row 0 -column 0 -columnspan 3 -sticky nsew
23 ## See Code / Dismiss buttons
24 set btns
[addSeeDismiss
$w.buttons
$w [list size color align
]]
25 grid $btns -row 3 -column 0 -columnspan 3 -sticky ew
27 labelframe $w.left
-pady 2 -text "Point Size" -padx 2
28 labelframe $w.mid
-pady 2 -text "Color" -padx 2
29 labelframe $w.right
-pady 2 -text "Alignment" -padx 2
30 button $w.tristate
-text Tristate
-command "set size multi; set color multi" \
32 if {[tk windowingsystem
] eq
"aqua"} {
33 $w.tristate configure
-padx 10
35 grid $w.left
-column 0 -row 1 -pady .5c
-padx .5c
-rowspan 2
36 grid $w.mid
-column 1 -row 1 -pady .5c
-padx .5c
-rowspan 2
37 grid $w.right
-column 2 -row 1 -pady .5c
-padx .5c
38 grid $w.tristate
-column 2 -row 2 -pady .5c
-padx .5c
40 foreach i
{10 12 14 18 24} {
41 radiobutton $w.left.b
$i -text "Point Size $i" -variable size
\
42 -relief flat
-value $i -tristatevalue "multi"
43 pack $w.left.b
$i -side top
-pady 2 -anchor w
-fill x
46 foreach c
{Red Green Blue Yellow Orange Purple
} {
47 set lower [string tolower
$c]
48 radiobutton $w.mid.
$lower -text $c -variable color
\
49 -relief flat
-value $lower -anchor w
\
50 -command "$w.mid configure -fg \$color" \
51 -tristatevalue "multi"
52 pack $w.mid.
$lower -side top
-pady 2 -fill x
56 label $w.right.l
-text "Label" -bitmap questhead
-compound left
57 $w.right.l configure
-width [winfo reqwidth
$w.right.l
] -compound top
58 $w.right.l configure
-height [winfo reqheight
$w.right.l
]
59 foreach a
{Top Left Right Bottom
} {
60 set lower [string tolower
$a]
61 radiobutton $w.right.
$lower -text $a -variable align
\
62 -relief flat
-value $lower -indicatoron 0 -width 7 \
63 -command "$w.right.l configure -compound \$align"
67 grid $w.right.left
$w.right.l
$w.right.right
68 grid x
$w.right.bottom