pymel.core.windows.menu

static windows.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  
   
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. Flag can have multiple arguments, passed either as a tuple or a list.
enable (en) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Enables/disables the menu.
exists (ex) bool  
   
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.
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.
tearOff (to) bool ../../../_images/create.gif
 
Makes the menu tear-off-able.
useTemplate (ut) unicode  
   
visible (vis) bool  
   

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.SubMenuItem('window1|menu43|menuItem549') #
pm.menuItem( label='Open' )
# Result: ui.SubMenuItem('window1|menu43|menuItem550') #
pm.menuItem( label='Save' )
# Result: ui.SubMenuItem('window1|menu43|menuItem551') #
pm.menuItem( divider=True )
# Result: ui.SubMenuItem('window1|menu43|menuItem552') #
pm.menuItem( label='Quit' )
# Result: ui.SubMenuItem('window1|menu43|menuItem553') #
pm.menu( label='Help', helpMenu=True )
# Result: ui.Menu('window1|menu44') #
pm.menuItem( 'Application..."', label='"About' )
# Result: ui.SubMenuItem('window1|menu44|Application____') #
pm.columnLayout()
# Result: ui.ColumnLayout('window1|columnLayout57') #
pm.button()
# Result: ui.Button('window1|columnLayout57|button49') #
pm.button()
# Result: ui.Button('window1|columnLayout57|button50') #
pm.button()
# Result: ui.Button('window1|columnLayout57|button51') #
pm.showWindow()

Previous topic

pymel.core.windows.lsUI

Next topic

pymel.core.windows.menuBarLayout

Core

Core Modules

Other Modules

This Page