Posted to tcl by dkf at Thu Feb 05 21:33:45 GMT 2015view raw
- set nval {}
- proc setLabel {idx} {
- set val [.fr.lb get $idx]
- .fr.lbl configure -text $val -foreground blue
- upvar ::nval y
- lappend y $val
- puts "The list is now '$y'"
- }
- frame .fr
- pack .fr -fill both -expand 1
- listbox .fr.lb
- .fr.lb insert end Scarlett Rachel Natalie Jessica
- .fr.lb insert 2 zaz
- bind .fr.lb <<ListboxSelect>> { setLabel [%W curselection]}
- .fr.lb configure -selectbackground pink
- place .fr.lb -x 20 -y 20
- label .fr.lbl
- place .fr.lbl -x 20 -y 210
- puts $nval
- wm title . listbox
- wm geometry . 300x250+300+300