OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/base.git] / util / src / TclTk / tk8.6.12 / library / demos / combo.tcl
1 # combo.tcl --
2 #
3 # This demonstration script creates several combobox widgets.
4
5 if {![info exists widgetDemo]} {
6     error "This script should be run from the \"widget\" demo."
7 }
8
9 package require Tk
10
11 set w .combo
12 catch {destroy $w}
13 toplevel $w
14 wm title $w "Combobox Demonstration"
15 wm iconname $w "combo"
16 positionWindow $w
17
18 ttk::label $w.msg -font $font -wraplength 5i -justify left -text "Three different\
19         combo-boxes are displayed below. You can add characters to the first\
20         one by pointing, clicking and typing, just as with an entry; pressing\
21         Return will cause the current value to be added to the list that is\
22         selectable from the drop-down list, and you can choose other values\
23         by pressing the Down key, using the arrow keys to pick another one,\
24         and pressing Return again. The second combo-box is fixed to a\
25         particular value, and cannot be modified at all. The third one only\
26         allows you to select values from its drop-down list of Australian\
27         cities."
28 pack $w.msg -side top -fill x
29
30 ## See Code / Dismiss buttons
31 set btns [addSeeDismiss $w.buttons $w {firstValue secondValue ozCity}]
32 pack $btns -side bottom -fill x
33
34 ttk::frame $w.f
35 pack $w.f -fill both -expand 1
36 set w $w.f
37
38 set australianCities {
39     Canberra Sydney Melbourne Perth Adelaide Brisbane
40     Hobart Darwin "Alice Springs"
41 }
42 set secondValue unchangable
43 set ozCity Sydney
44
45 ttk::labelframe $w.c1 -text "Fully Editable"
46 ttk::combobox $w.c1.c -textvariable firstValue
47 ttk::labelframe $w.c2 -text Disabled
48 ttk::combobox $w.c2.c -textvariable secondValue -state disabled
49 ttk::labelframe $w.c3 -text "Defined List Only"
50 ttk::combobox $w.c3.c -textvariable ozCity -state readonly \
51         -values $australianCities
52 bind $w.c1.c <Return> {
53     if {[%W get] ni [%W cget -values]} {
54         %W configure -values [concat [%W cget -values] [list [%W get]]]
55     }
56 }
57
58 pack $w.c1 $w.c2 $w.c3 -side top -pady 5 -padx 10
59 pack $w.c1.c -pady 5 -padx 10
60 pack $w.c2.c -pady 5 -padx 10
61 pack $w.c3.c -pady 5 -padx 10