|
Selectionbox
The selectionbox iwidget combines a scrolled list of items, an editable entry field for the selected item, and labels for the list and entry field, allowing the user to select or enter one item from a list of alternatives. The Selectionbox also provides a child site and an option to control its position.
For further information, see the Selectionbox
manpage
Components: hull items selection
|
wm title . "Selectionbox Example"
##
## Helper procs
##
proc entrySelect {} {
puts "Entry value: [.sb component selection get]"
return
}; # end proc entrySelect
proc listSelect {} {
puts "Listbox value: [.sb get]"
.sb selectitem
return
}; # end proc listSelect
##=========================================================
## Create a selectionbox iwidget
##=========================================================
##
iwidgets::selectionbox .sb \
-childsitepos w \
-selectioncommand entrySelect \
-itemscommand listSelect \
-selectbackground blue \
-selectforeground white
pack .sb
##
## Add another label in the childsite
##
font create lbl_font \
-family Helvetica \
-size 16 \
-weight bold
set cs [.sb childsite]
label $cs.label \
-text [join [split " Iwidgets Library" ""] \n] \
-foreground blue \
-font lbl_font
pack $cs.label \
-padx 4 \
-pady 4
##
## Add some items to the listbox
##
cd ${iwidgets::library}/scripts
eval .sb insert items end [glob -nocomplain *.itk]
|
Download this sample code |
|