programming:tcl/tk:tk_menusWhat links here?
menubutton

A menubutton is a widget that displays a textual string, bitmap, or image and is associated with a menu widget.In normal usage, pressing left-clicking the menubutton causes the associated menu to be posted just underneath the menubutton.

Some Options:

menu
A menu is a widget that displays a collection of one-line entries arranged in one or more columns. There exist several different types of entries, each with different properties. Entries of different types may be combined in a single menu. Menu entries are not the same as entry widgets. In fact, menu entries are not even distinct widgets; the entire menu is one widget.

Some Options:

Some Commands

Syntax Description





Example

proc menu_clicked { no opt }
 {
	tk_messageBox -message \
		"You have clicked $opt.\nThis function is not implanted yet."
}


  1. Declare that there is a menu menu .mbar . config -menu .mbar


  1. The Main Buttons .mbar add cascade -label "File" -underline 0 \ -menu [menu .mbar.file -tearoff 0].mbar add cascade -label "Others" \ -underline 0 -menu [menu .mbar.oth -tearoff 1].mbar add cascade -label "Help" -underline 0 \ -menu [menu .mbar.help -tearoff 0]


    1. File Menu ## set m .mbar.file $m add command -label "New" -underline 0 \ -command { .txt delete 1.0 end } ;# A new item called New is added. $m add checkbutton -label "Open" -underline 0 -command { menu_clicked 1 "Open" } $m add command -label "Save" -underline 0 -command { menu_clicked 1 "Save" } $m add separator $m add command -label "Exit" -underline 1 -command exit


    1. Others Menu ## set m .mbar.oth $m add cascade -label "Insert" -underline 0 -menu [menu $m.mnu -title "Insert"] $m.mnu add command -label "Name" \ -command { .txt insert end "Name : Binny V A\n"} $m.mnu add command -label "Website" -command { \ .txt insert end "Website: http://www.bin-co.com/\n"} $m.mnu add command -label "Email" \ -command { .txt insert end "E-Mail : binnyva@hotmail.com\n"} $m add command -label "Insert All" -underline 7 \ -command Website : http://www.bin-co.com/ E-Mail : binnyva@hotmail.com} }


    1. Help ## set m .mbar.help $m add command -label "About" -command { .txt delete 1.0 end .txt insert end { About ---------- This script created to make a menu for a tcl/tk tutorial. Made by Binny V A Website : http://www.bin-co.com/ E-Mail : binnyva@hotmail.com } }


  1. Making a text area text .txt -width 50 pack .txt


Create the main buttons as cascade menus and create the menus as their slaves. For more information see the manual.

tk:tk_menus
filename:programming:tcl/tk:tk_menus
filename:programming%3Atcl%2Ftk%3Atk_menus
last edit:March 31 2009 21:45:36 (5514 days ago)
ct = 1714989789.000000 = May 06 2024 06:03:09
ft = 1238550336.000000 = March 31 2009 21:45:36
dt = 476439453.000000