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