proc tk_getChoice {w var title text prompt start args} { global $var variable ::tk::Priv catch {unset $var} catch {destroy $w} set focus [focus] set grab [grab current .] toplevel $w -bd 1 -relief raised -class TkSDialog wm title $w $title wm iconname $w $title wm protocol $w WM_DELETE_WINDOW {set ::tk::Priv(button) 0} wm transient $w [winfo toplevel [winfo parent $w]] if {$prompt != ""} { set menu [tk_optionMenu $w.menu $var $prompt] $menu delete 0 foreach x $args {$menu add radiobutton -label $x -variable $var} } else { set menu [eval tk_optionMenu $w.menu $var $args] if {$start != ""} {set $var $start} } $w.menu configure -width 25 button $w.ok -bd 1 -text Ok -default active -command {set ::tk::Priv(button) 1} button $w.cancel -bd 1 -text Cancel -command {set ::tk::Priv(button) 0} label $w.label -text $text if {$text != ""} {grid $w.label -columnspan 2 -sticky ew -padx 3 -pady 3} grid $w.menu -columnspan 2 -sticky ew -padx 3 -pady 3 grid $w.ok $w.cancel -padx 3 -pady 3 grid rowconfigure $w 2 -weight 1 grid columnconfigure $w {0 1} -uniform 1 -weight 1 bind $w {set ::tk::Priv(button) 1} bind $w {set ::tk::Priv(button) 0} bind $w {set ::tk::Priv(button) 0} wm withdraw $w update idletasks set x [expr {[winfo screenwidth $w]/2 - [winfo reqwidth $w]/2 - [winfo vrootx $w]}] set y [expr {[winfo screenheight $w]/2 - [winfo reqheight $w]/2 - [winfo vrooty $w]}] wm geom $w +$x+$y wm deiconify $w grab $w tkwait variable ::tk::Priv(button) bind $w {} grab release $w destroy $w focus -force $focus if {$grab != ""} {grab $grab} update idletasks return $::tk::Priv(button) } ---- usage: tk_getChoice w var title text prompt start args w: toplevel name var: global variable in which the result is stored title: title of the toplevel text: text for the prompt over the option menu, may be set to null if you do not wish for a static prompt prompt: the initial display of the option menu, this prompt is NOT one of the selectable values, it will disappear when a value is selected start: set the initial selected value, this option is ignored if the prompt is not null args: the values that will be selectable in the option menu usage examples: tk_getOption .opt result "Option Dialog" "Please choose an option" {} three one one two three four five six tk_getOption .opt result "Option Dialog" {} "Choose an option" {} one one two three four five six --AF 24-06-03