[Image of Linux]
The Personal Web Pages of Chris X. Edwards

A Simplified Tk Reference

--------------------------
Keyword:

menu

Description: Comprehensive menu widget supporting standard menus across the top of a container object. It also supports cascading menu structure as well as tear off menus.
Example:

. configure -width 400
menu .tree -bg green
.tree add cascade -label Pine -underline 0 -menu .tree.pine
.tree add cascade -background tan -label Hardwood -underline 0 -menu .tree.hard
.tree add cascade -label Tropical -underline 0 -menu .tree.tropic
.tree add cascade -label Fruit -underline 0 -menu .tree.fruit
menu .tree.pine 
.tree.pine add command -label "Douglas Fir" -underline 8 -command {puts Df}
.tree.pine add command -label Spruce -underline 0 -command {puts Sp}
.tree.pine add command -label Sequoia -underline 2 -command {puts Sq}
menu .tree.hard
.tree.hard add command -label Hickory -underline 0 -command {puts Hi}
.tree.hard add command -label Oak -underline 0 -command {puts Ok}
menu .tree.tropic
.tree.tropic add command -label Mahogany -underline 0 -command {puts Mh}
.tree.tropic add command -label Teak -underline 0 -command {puts Tk}
.tree.tropic add command -label Cocobolo -underline 0 -command {puts Co}
menu .tree.fruit -background pink
.tree.fruit add command -label Apple -underline 0 -background green -command {puts Ap}
.tree.fruit add command -label Banana -underline 0 -background yellow -command {puts Ba}
.tree.fruit add command -label Cherry -foreground white -underline 0 -background red -command {puts Ch}
.tree.fruit add separator -background black
.tree.fruit add cascade -label Citrus -underline 5 -menu .tree.fruit.citrus
menu .tree.fruit.citrus -tearoff 0
.tree.fruit.citrus add command -label Orange -underline 0 -background orange -command {puts Or}
.tree.fruit.citrus add command -label Grapefruit -underline 0 -background pink -command {puts Gf}
.tree.fruit.citrus add command -label Lemon -underline 1 -background yellow -command {puts Le}
.tree.fruit.citrus add command -label Lime -underline 1 -background green -command {puts Li}
. configure -menu .tree; #Or try this: toplevel .tl -menu .tree; wm title .tl "Tree Selector"

  
Official
Syntax:
http://www.scriptics.com/man/tcl8.4/TkCmd/menu.htm

--------------------------
Previous Home Next
This page was created with only free, open-source, publicly licensed software.
This page was designed to be viewed with any browser on any system.
Chris X. Edwards ~ January 2004