tk_optionMenu

(#<parent-widget> 'create-widget "tk_optionMenu" (tk-var varName) value1 ?value2 ...?)
creates a new option menubutton widget which is a descendant of #<parent-widget>.

It contains as a child widget a menu the entries of which are bound to the Tcl/Tk variable represented by (tk-var varName).

Together they allow the user to select one of the values given by the value arguments. The current value will be stored in the Tcl/Tk variable represented by (tk-var varName) and it will also be displayed as the label in the option menubutton. The user can click on the menubutton to display a menu containing all of the values and thereby select a new value.

Once a new value is selected, it will be stored in the variable and appear in the option menubutton.

You can gain access to the child menu as in this example:

(define button1 
  (tk 'create-widget "tk_optionMenu"
      (tk-var "globalOption")
      "alpha" "beta" "gamma"))

(tk/pack button1)

(define button1menu
  (tk-id->widget
     (tk/winfo children button1)))

The current value of the variable can be read as in this example:

(get-tk-var "globalOption")

The current value can be changed by setting the variable as in this example:

(set-tk-var! "globalOption" "gamma")

tk_optionMenu


© Author | Home | Sitemap