diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2007-10-22 14:21:04 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2007-10-22 14:21:04 (GMT) |
commit | dfdf99ed53285ece3a7ca2ca269a205b4c3b69e2 (patch) | |
tree | 7ef16e41ec928fc20b1bdd0789ce7a846ccddd40 /library/demos/combo.tcl | |
parent | da9f8e86e69b0f5266067190d85b3c6bdf4fd7fa (diff) | |
download | tk-dfdf99ed53285ece3a7ca2ca269a205b4c3b69e2.zip tk-dfdf99ed53285ece3a7ca2ca269a205b4c3b69e2.tar.gz tk-dfdf99ed53285ece3a7ca2ca269a205b4c3b69e2.tar.bz2 |
More widget demos!
Diffstat (limited to 'library/demos/combo.tcl')
-rw-r--r-- | library/demos/combo.tcl | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/library/demos/combo.tcl b/library/demos/combo.tcl new file mode 100644 index 0000000..ed9c585 --- /dev/null +++ b/library/demos/combo.tcl @@ -0,0 +1,60 @@ +# combo.tcl -- +# +# This demonstration script creates several combobox widgets. +# +# RCS: @(#) $Id: combo.tcl,v 1.1 2007/10/22 14:21:10 dkf Exp $ + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk +package require Ttk + +set w .combo +catch {destroy $w} +toplevel $w +wm title $w "Combobox Demonstration" +wm iconname $w "combo" +positionWindow $w + +label $w.msg -font $font -wraplength 5i -justify left -text "Three different\ + combo-boxes are displayed below. You can add characters to the first\ + one by pointing, clicking and typing, just as with an entry; pressing\ + Return will cause the current value to be added to the list that is\ + selectable from the drop-down list, and you can choose other values\ + by pressing the Down key, using the arrow keys to pick another one,\ + and pressing Return again. The second combo-box is fixed to a\ + particular value, and cannot be modified at all. The third one only\ + allows you to select values from its drop-down list of Australian\ + cities." +pack $w.msg -side top + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w {firstValue secondValue ozCity}] +pack $btns -side bottom -fill x + +set australianCities { + Canberra Sydney Melbourne Perth Adelaide Brisbane + Hobart Darwin "Alice Springs" +} +set secondValue unchangable +set ozCity Sydney + +ttk::labelframe $w.c1 -text "Fully Editable" +ttk::combobox $w.c1.c -textvariable firstValue +ttk::labelframe $w.c2 -text Disabled +ttk::combobox $w.c2.c -textvariable secondValue -state disabled +ttk::labelframe $w.c3 -text "Defined List Only" +ttk::combobox $w.c3.c -textvariable ozCity -state readonly \ + -values $australianCities +bind $w.c1.c <Return> { + if {[%W get] ni [%W cget -values]} { + %W configure -values [concat [%W cget -values] [list [%W get]]] + } +} + +pack $w.c1 $w.c2 $w.c3 -side top -pady 5 -padx 10 +pack $w.c1.c -pady 5 -padx 10 +pack $w.c2.c -pady 5 -padx 10 +pack $w.c3.c -pady 5 -padx 10 |