OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/hostdependX86LINUX64.git] / util / X86LINUX64 / lib / tk8.6 / demos / labelframe.tcl
1 # labelframe.tcl --
2 #
3 # This demonstration script creates a toplevel window containing
4 # several labelframe widgets.
5
6 if {![info exists widgetDemo]} {
7     error "This script should be run from the \"widget\" demo."
8 }
9
10 package require Tk
11
12 set w .labelframe
13 catch {destroy $w}
14 toplevel $w
15 wm title $w "Labelframe Demonstration"
16 wm iconname $w "labelframe"
17 positionWindow $w
18
19 # Some information
20
21 label $w.msg -font $font -wraplength 4i -justify left -text "Labelframes are\
22         used to group related widgets together.  The label may be either \
23         plain text or another widget."
24 pack $w.msg -side top
25
26 ## See Code / Dismiss buttons
27 set btns [addSeeDismiss $w.buttons $w]
28 pack $btns -side bottom -fill x
29
30 # Demo area
31
32 frame $w.f
33 pack $w.f -side bottom -fill both -expand 1
34 set w $w.f
35
36 # A group of radiobuttons in a labelframe
37
38 labelframe $w.f -text "Value" -padx 2 -pady 2
39 grid $w.f -row 0 -column 0 -pady 2m -padx 2m
40
41 foreach value {1 2 3 4} {
42     radiobutton $w.f.b$value -text "This is value $value" \
43             -variable lfdummy -value $value
44     pack $w.f.b$value -side top -fill x -pady 2
45 }
46
47
48 # Using a label window to control a group of options.
49
50 proc lfEnableButtons {w} {
51     foreach child [winfo children $w] {
52         if {$child == "$w.cb"} continue
53         if {$::lfdummy2} {
54             $child configure -state normal
55         } else {
56             $child configure -state disabled
57         }
58     }
59 }
60
61 labelframe $w.f2 -pady 2 -padx 2
62 checkbutton $w.f2.cb -text "Use this option." -variable lfdummy2 \
63         -command "lfEnableButtons $w.f2" -padx 0
64 $w.f2 configure -labelwidget $w.f2.cb
65 grid $w.f2 -row 0 -column 1 -pady 2m -padx 2m
66
67 set t 0
68 foreach str {Option1 Option2 Option3} {
69     checkbutton $w.f2.b$t -text $str
70     pack $w.f2.b$t -side top -fill x -pady 2
71     incr t
72 }
73 lfEnableButtons $w.f2
74
75
76 grid columnconfigure $w {0 1} -weight 1