|
Optionmenu
The optionmenu iwidget allows selection of one item from a set of items. Only the selected item is displayed, until the user selects the option menu button and a popup menu appears with all the choices available for selection. Once a new item is chosen, the currently selected item is replaced and the popup is removed from the display. Commands exist for manipulating the menu list contents as well. These include the ability to insert, delete, select, disable, enable, and sort items.
For further information, see the Optionmenu
manpage
Components: hull label menuBtn popupMenu
|
wm title . "Optionmenu Example"
##
## supporting procedure
##
proc selectProc {} {
set os [.om get]
puts "The OS chosen is $os"
return
}; # end selectProc proc
##=========================================================
## Create an optionmenu iwidget
##=========================================================
##
iwidgets::optionmenu .om \
-labeltext "Operating Systems:" \
-command selectProc
pack .om \
-padx 10 \
-pady 10
##
## Insert items into the list
##
foreach o {SunOS HP/UX AIX OS/2 Windows DOS Linux VMS} {
.om insert end $o
}
##
## post configure the menu
##
.om delete 1 2
.om sort ascending
.om select Linux
.om configure \
-cyclicon true
|
Download this sample code |
|