pymel.core.windows.menu

menu(*args, **kwargs)

This command creates a new menu and adds it to the default window’s menubar if no parent is specified. The menu can be enabled/disabled. Note that this command may also be used on menu objects created using the command menuItem -sm/subMenu true.

Modifications
  • added ability to query parent

Flags:

Long Name / Short Name Argument Types Properties
allowOptionBoxes / aob bool ../../../_images/create.gif ../../../_images/query.gif
  Deprecated. All menus now always allow option boxes. Indicate whether the menu will be able to support option box menu items.
defineTemplate / dt unicode ../../../_images/create.gif
  Puts the command in a mode where any other flags and arguments are parsed and added to the command template specified in the argument. They will be used as default arguments in any subsequent invocations of the command when templateName is set as the current template.
deleteAllItems / dai bool ../../../_images/create.gif ../../../_images/edit.gif
  Delete all the items in this menu.
docTag / dtg unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Attaches a tag to the menu.
enable / en bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Enables/disables the menu.
exists / ex bool ../../../_images/create.gif
  Returns whether the specified object exists or not. Other flags are ignored.
familyImage / fi unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  The filename of the icon associated with the menu. This icon will be used if a menu item does not have an icon image defined.
helpMenu / hm bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Indicates that this menu is the help menu and will be the right most menu in the menu bar. On Unix systems the help menu is also right justified in the menu bar.
itemArray / ia bool ../../../_images/query.gif
  Return string array of the menu item names.
label / l unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  The text that is displayed for the menu. If no label is supplied then the menuName will be used.
ltVersion / lt unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  This flag is used to specify the Maya LT version that this control feature was introduced, if the version flag is not specified, or if the version flag is specified but its argument is different. This value is only used by Maya LT, and otherwise ignored. The argument should be given as a string of the version number (e.g. 2014, 2015). Currently only accepts major version numbers (e.g. 2014.5 should be given as 2014).
mnemonic / mn unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Set the Alt key to post that menu. The character specified must match the case of its corresponding character in the menu item text, but selection from the keyboard is case insensitive.
numberOfItems / ni bool ../../../_images/query.gif
  Return number of items in the menu.
parent / p unicode ../../../_images/create.gif
  Specify the window that the menu will appear in.
postMenuCommand / pmc script ../../../_images/create.gif ../../../_images/edit.gif
  Specify a script to be executed when the menu is about to be shown.
postMenuCommandOnce / pmo bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Indicate the -pmc/postMenuCommandshould only be invoked once. Default value is false, ie. the -pmc/postMenuCommandis invoked every time the menu is shown.
scrollable / srb bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Make the popup menus support scrolling. Default value is false.
tearOff / to bool ../../../_images/create.gif
  Makes the menu tear-off-able.
useTemplate / ut unicode ../../../_images/create.gif
  Forces the command to use a command template other than the current one.
version / ver unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Specify the version that this menu feature was introduced. The argument should be given as a string of the version number (e.g. 2014, 2015). Currently only accepts major version numbers (e.g. 2014.5 should be given as 2014).
visible / vis bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Shows/hides the menu. Flag can have multiple arguments, passed either as a tuple or a list.

Derived from mel command maya.cmds.menu

Example:

import pymel.core as pm

pm.window( menuBar=True, width=200 )
# Result: ui.Window('window1') #
pm.menu( label='File', tearOff=True )
# Result: ui.Menu('window1|menu43') #
pm.menuItem( label='New' )
# Result: ui.CommandMenuItem('window1|menu43|menuItem465') #
pm.menuItem( label='Open' )
# Result: ui.CommandMenuItem('window1|menu43|menuItem466') #
pm.menuItem( label='Save' )
# Result: ui.CommandMenuItem('window1|menu43|menuItem467') #
pm.menuItem( divider=True )
# Result: ui.CommandMenuItem('window1|menu43|menuItem468') #
pm.menuItem( label='Quit' )
# Result: ui.CommandMenuItem('window1|menu43|menuItem469') #
pm.menu( label='Help', helpMenu=True )
# Result: ui.Menu('window1|menu44') #
pm.menuItem( 'Application..."', label='"About' )
# Result: ui.CommandMenuItem('window1|menu44|Application____') #
pm.columnLayout()
# Result: ui.ColumnLayout('window1|columnLayout57') #
pm.button()
# Result: ui.Button('window1|columnLayout57|button50') #
pm.button()
# Result: ui.Button('window1|columnLayout57|button51') #
pm.button()
# Result: ui.Button('window1|columnLayout57|button52') #
pm.showWindow()