Update tk to version 8.5.11
[git/jnareb-git.git] / mingw / lib / tk8.5 / demos / radio.tcl
blob5c737033e62ace2815254f926fd3ec8ff63041c1
1 # radio.tcl --
3 # This demonstration script creates a toplevel window containing
4 # several radiobutton widgets.
6 if {![info exists widgetDemo]} {
7 error "This script should be run from the \"widget\" demo."
10 package require Tk
12 set w .radio
13 catch {destroy $w}
14 toplevel $w
15 wm title $w "Radiobutton Demonstration"
16 wm iconname $w "radio"
17 positionWindow $w
18 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."
19 grid $w.msg -row 0 -column 0 -columnspan 3 -sticky nsew
21 ## See Code / Dismiss buttons
22 set btns [addSeeDismiss $w.buttons $w [list size color align]]
23 grid $btns -row 3 -column 0 -columnspan 3 -sticky ew
25 labelframe $w.left -pady 2 -text "Point Size" -padx 2
26 labelframe $w.mid -pady 2 -text "Color" -padx 2
27 labelframe $w.right -pady 2 -text "Alignment" -padx 2
28 button $w.tristate -text Tristate -command "set size multi; set color multi" \
29 -pady 2 -padx 2
30 if {[tk windowingsystem] eq "aqua"} {
31 $w.tristate configure -padx 10
33 grid $w.left -column 0 -row 1 -pady .5c -padx .5c -rowspan 2
34 grid $w.mid -column 1 -row 1 -pady .5c -padx .5c -rowspan 2
35 grid $w.right -column 2 -row 1 -pady .5c -padx .5c
36 grid $w.tristate -column 2 -row 2 -pady .5c -padx .5c
38 foreach i {10 12 14 18 24} {
39 radiobutton $w.left.b$i -text "Point Size $i" -variable size \
40 -relief flat -value $i -tristatevalue "multi"
41 pack $w.left.b$i -side top -pady 2 -anchor w -fill x
44 foreach c {Red Green Blue Yellow Orange Purple} {
45 set lower [string tolower $c]
46 radiobutton $w.mid.$lower -text $c -variable color \
47 -relief flat -value $lower -anchor w \
48 -command "$w.mid configure -fg \$color" \
49 -tristatevalue "multi"
50 pack $w.mid.$lower -side top -pady 2 -fill x
54 label $w.right.l -text "Label" -bitmap questhead -compound left
55 $w.right.l configure -width [winfo reqwidth $w.right.l] -compound top
56 $w.right.l configure -height [winfo reqheight $w.right.l]
57 foreach a {Top Left Right Bottom} {
58 set lower [string tolower $a]
59 radiobutton $w.right.$lower -text $a -variable align \
60 -relief flat -value $lower -indicatoron 0 -width 7 \
61 -command "$w.right.l configure -compound \$align"
64 grid x $w.right.top
65 grid $w.right.left $w.right.l $w.right.right
66 grid x $w.right.bottom