This is a useful compatibilty function to tk's tk_optionMenu:
# ttk::optionmenu --
#
# This procedure creates an option button named $w and an
associated
# menu. Together they provide the functionality of Motif
option menus:
# they can be used to select one of many values, and the
current value
# appears in the global variable varName, as well as in the
text of
# the option menubutton. The name of the menu is returned
as the
# procedure's result, so that the caller can use it to change
configuration
# options on the menu or otherwise manipulate it.
#
# Arguments:
# w - The name to use for the menubutton.
# varName - Global variable to hold the currently
selected value.
# firstValue - First of legal values for option (must be
>= 1).
# args - Any number of additional values.
proc ttk::optionmenu {w varName firstValue args} {
upvar #0 $varName var
if {![info exists var]} {
set var $firstValue
}
ttk::menubutton $w -textvariable $varName -menu
$w.menu -direction flush
menu $w.menu -tearoff 0
$w.menu add radiobutton -label $firstValue -variable
$varName
foreach i $args {
$w.menu add radiobutton -label $i -variable $varName
}
return $w.menu
}
Mats