Previous: Scrolling and scrollbar widgets
Up: Widgets
Previous Page: Scrolling and scrollbar widgets
Next Page: Example applications

Menus

The following example shows how to develop a simple menu, with three options. When the menu button is activated by a button 1 press, the menu drops down ready for selection.

If the menu button is activated by a button 2 press, the menu drops down, and can be "torn off", and positioned anywhere on the screen. To revert to normal menu mode, the menu button should be re-activated by a button 1 press.

#First make a menu button
    menubutton .menu1 -text "Unix commands" -menu .menu1.m  
    	-underline 0

#Now make the menu, and add the lines one at a time menu .menu1.m .menu1.m add command -label "List Files" -command {ls} .menu1.m add command -label "Get date" -command {date} .menu1.m add command -label "Start calendar" -command {xcalendar}

pack .menu1

Apologies to all those readers who don't like Unix!

csstddm@brunel.ac.uk
Fri Aug 19 16:55:19 BST 1994