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 Deprecated. All menus now always allow option boxes. Indicate whether the menu will be able to support option box menu items. defineTemplate / dt unicode deleteAllItems / dai bool Delete all the items in this menu. docTag / dtg unicode Attaches a tag to the menu. enable / en bool Enables/disables the menu. exists / ex bool familyImage / fi unicode 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 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 Return string array of the menu item names. label / l unicode The text that is displayed for the menu. If no label is supplied then the menuName will be used. ltVersion / lt unicode 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 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 Return number of items in the menu. parent / p unicode Specify the window that the menu will appear in. postMenuCommand / pmc script Specify a script to be executed when the menu is about to be shown. postMenuCommandOnce / pmo bool Indicate the -pmc/postMenuCommandshould only be invoked once. Default value is false, ie. the -pmc/postMenuCommandis invoked every time the menu is shown. tearOff / to bool Makes the menu tear-off-able. useTemplate / ut unicode version / ver unicode 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 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()