Table of Contents Previous page Next page Index

ModelSim Documentation Bookcase

Model Technology Inc.


add_menu

The add_menu command adds a menu to the menu bar of the specified window, using the specified menu name. Use the add_menuitem, add_separator, add_menucb, and add_submenu commands to complete the menu.

Returns the full Tk pathname of the new menu.

Color and other Tk properties of the menu may be changed, after creating the menu, using the Tk menu widget configure command.

Syntax

add_menu

<window_name> <menu_name> [<shortcut>] [-hide_menubutton]

Arguments

<window_name>

Tk path of the window to contain the menu. Required.

Note that the path for the Main window must be expressed as "". All other window pathnames begin with a period (.) as shown in the example below.

<menu_name>

Name to be given to the Tk menu widget. Required.

<shortcut>

Number of the letter in the menu name that is to be used as the shortcut. Numbering starts with 0 (i.e., first letter = 0, second letter = 1, third letter = 2, etc.). Optional. Default is "1", which indicates no shortcut is to be used.

-hide_menubutton

Causes the new menu not to be displayed. Optional. You can add the menu later by calling tk-popup on the menu path widget.

Examples

The following Tcl code is an example of creating user-customized menus. It adds a menu containing a top-level item labeled "Do My Own Thing...", which prints "my_own_thing.signals", and adds a cascading submenu labeled "changeCase" with two entries, "To Upper" and "To Lower", which echo "my_to_upper" and "my_to_lower" respectively. A checkbox that controls the value of myglobalvar (.signals:one) is also added.

view signals
set myglobalvar(.signals:one) 0
set myglobalvar(.signals:two) 1
proc AddMyMenus {wname} { 
    global myglobalvar
    set cmd1 "echo my_own_thing $wname"
    set cmd2 "echo my_to_upper  $wname"
    set cmd3 "echo my_to_lower  $wname"

    #              WindowName  Menu   MenuItem label        Command
    #              ----------  ----   --------------------  -------
    add_menu       $wname      mine   0;# 0th letter (M) is underlined
    add_menuitem   $wname      mine   "Do My Own Thing..."  $cmd1
    add_separator  $wname      mine   ;#----------------------------
    add_submenu    $wname      mine   changeCase
    add_menuitem   $wname      mine.changeCase "To Upper"   $cmd2
    add_menuitem   $wname      mine.changeCase "To Lower"   $cmd3
    add_submenu    $wname      mine   vars
    add_menucb     $wname      mine.vars "Feature One"      -variable 
                                              myglobalvar($wname:one) 
                                 -onvalue 1 -offvalue 0 -indicatoron 1
}
AddMyMenus .signals 

This example is available in the following DO file: <install_dir>/modeltech/examples/addmenu.do. You can run the DO file to add the "Mine" menu shown in the illustration, or modify the file for different results.

To execute the DO file, select Macro > Execute Macro from the Main window menu bar, or use the do command from the ModelSim command line.

See also

add_menucb, add_menuitem, add_separator, add_submenu, change_menu_cmd


Model Technology Inc.
Model Technology Incorporated
Voice: (503) 641-1340
Fax: (503)526-5410
www.model.com
sales@model.com
Table of Contents Previous page Next page Index

ModelSim Documentation Bookcase