pymel.core.windows.menuItem

static windows.menuItem(*args, **kwargs)

This command creates/edits/queries menu items.

Flags:
Long name (short name) Argument Types Properties
allowOptionBoxes (aob) bool ../../../_images/create.gif ../../../_images/query.gif
 

Deprecated. All menus and menu items always allow option boxes. In the case of submenu items this flag specifies whether the submenu will be able to support option box menu items. Always returns true.

altModifier (alt) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Specify this flag if the Alt modifier is part of the accelerator sequence.
annotation (ann) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Annotate the menu item with an extra string value.
boldFont (bld) bool ../../../_images/create.gif ../../../_images/query.gif
 

Specify if text should be bold. Only supported in menus which use the marking menu implementation. Default is false for Windows, and true for all other platforms. Flag can have multiple arguments, passed either as a tuple or a list.

checkBox (cb) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Creates a check box menu item. Argument specifies the check box value.
collection (cl) unicode ../../../_images/create.gif ../../../_images/query.gif
 
To explicitly add a radio menu item to a radioMenuItemCollection.
command (c) script ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Attaches a command/script that will be executed when the item is selected. Note this command is not executed when the menu item is in an optionMenucontrol.
commandModifier (cmd) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Specify this flag if the command modifier is part of the accelerator sequence. This is only available on systems which have a separate command key.
ctrlModifier (ctl) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Specify this flag if the Cntl modifier is part of the accelerator sequence.
data (da) int ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Attaches a piece of user-defined data to the menu item.
defineTemplate (dt) unicode  
   
divider (d) bool ../../../_images/create.gif ../../../_images/query.gif
 
Creates a divider menu item.
docTag (dtg) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Attaches a tag to the menu item.
dragDoubleClickCommand (ddc) script ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
If the menu item is put on the shelf then this command will be invoked when the corresponding shelf object is double clicked.
dragMenuCommand (dmc) script ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
If the menu item is put on the shelf then this command will be invoked when the corresponding shelf object is clicked.
echoCommand (ec) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 

Specify whether the action attached with the c/commandflag should echo to the command output areas when invoked. This flag is false by default and must be specified with the c/commandflag.

enable (en) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Enable state for the menu item. A disabled menu item is dimmed and unresponsive. An enabled menu item is selectable and has normal appearance.
enableCommandRepeat (ecr) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 

This flag only affects menu items to which a command can be attached. Specify true and the command may be repeated by executing the command repeatLast. This flag is true by default for all items except for option box items.

exists (ex) bool  
   
familyImage (fi) unicode ../../../_images/query.gif
 
Get the filename of the family icon associated with the menu. The family icon will be used for the shelf unless an icon is specified with the imageflag.
image (i) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 

The filename of the icon associated with the menu item. If the menu containing the menu item is being edited with a menuEditor widget, then the menuEditor will use this icon to represent the menu item. This icon will be displayed on the shelf when the menu item is placed there.

imageOverlayLabel (iol) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 

Specify a short (5 character) text string to be overlayed on top of the icon associated with the menu item. This is primarily a mechanism for differentiating menu items that are using a Family icon due to the fact that an icon image had not been explicitly defined. The image overlay label will not be used if an icon image is defined for the menu item.

insertAfter (ia) unicode ../../../_images/create.gif
 

Specify After which item the new one will be placed. If this flag is not specified, item is added at the end of the menu. Use the empty string to insert before the first item of the menu.WARNING: This flag is known to cause problems with tear off menus. It is recommended that you do not use it with menus that are tear off enabled. In other words, the parent menu should not have its to/tearOff flag set.

isCheckBox (icb) bool ../../../_images/query.gif
 
Returns true if the item is a check box item.
isOptionBox (iob) bool ../../../_images/query.gif
 
Returns true if the item is an option box item.
isRadioButton (irb) bool ../../../_images/query.gif
 
Returns true if the item is a radio button item.
italicized (itl) bool ../../../_images/create.gif ../../../_images/query.gif
 
Specify if text should be italicized. Only supported in menus which use the marking menu implementation. Default is false.
keyEquivalent (ke) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 

Specify the accelerator character. This character is combined with the modifier keys specified with the alt/altModifier, opt/optionModifier, ctl/ctlModifier, cmd/commandModifierand sh/shiftModifierto form the complete accelerator sequence that you can type to execute the menu item. Note that only regular menu items, radio menu items and check box menu items can have an accelerator.

label (l) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
The text that appears in the item.
mnemonic (mn) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 

Set the Alt key to activate that item. The character specified must match the case of its corresponding character in the menu item text, but selection from the keyboard is case insensitive.

optionBox (ob) bool ../../../_images/create.gif ../../../_images/query.gif
 
Indicates that the menu item will be an option box item. This item will appear to the right of the preceeding menu item.
optionModifier (opt) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Specify this flag if the Alt (or option) modifier is part of the accelerator sequence.
parent (p) unicode ../../../_images/create.gif
 
Specify the menu that the item will appear in.
postMenuCommand (pmc) script ../../../_images/create.gif ../../../_images/edit.gif
 
Specify a script to be executed when the submenu 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 everytime the sub menu is shown.
radialPosition (rp) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 

The radial position of the menu item if it is in a Marking Menu. Radial positions are given in the form of a cardinal direction, and may be N, NW, W, SW, S, SE, Eor NE.

radioButton (rb) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Creates a radio button menu item. Argument specifies the radio button value.
shiftModifier (sh) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Specify this flag if the Shift modifier is part of the accelerator sequence.
sourceType (stp) unicode  
   
subMenu (sm) bool ../../../_images/create.gif ../../../_images/query.gif
 

Indicates that the item will have a submenu. Subsequent menuItems will be added to the submenu until setParent -menuis called. Note that a submenu item creates a menu object and consequently the menucommand may be used on the submenu item.

tearOff (to) bool ../../../_images/create.gif ../../../_images/query.gif
 
For the case where the menu item is a sub menu this flag will make the sub menu tear-off-able. Note that this flag has no effect on the other menu item types.
useTemplate (ut) unicode  
   

Derived from mel command maya.cmds.menuItem

Example:

import pymel.core as pm

pm.window( menuBar=True, width=200 )
# Result: ui.Window('window1') #
pm.menu( label='Stuff' )
# Result: ui.Menu('window1|menu49') #
pm.menuItem( subMenu=True, label='Colors' )
# Result: ui.SubMenuItem('window1|menu49|menuItem563') #
pm.menuItem( label='Blue' )
# Result: ui.SubMenuItem('window1|menu49|menuItem563|menuItem564') #
pm.menuItem( label='Green' )
# Result: ui.SubMenuItem('window1|menu49|menuItem563|menuItem565') #
pm.menuItem( label='Yellow' )
# Result: ui.SubMenuItem('window1|menu49|menuItem563|menuItem566') #
pm.setParent( '..', menu=True )
# Result: u'window1|menu49' #
pm.menuItem( divider=True )
# Result: ui.SubMenuItem('window1|menu49|menuItem567') #
pm.radioMenuItemCollection()
# Result: ui.RadioMenuItemCollection('window1|menu49|radioMenuItemCollection8') #
pm.menuItem( label='Yes', radioButton=False )
# Result: ui.SubMenuItem('window1|menu49|menuItem568') #
pm.menuItem( label='Maybe', radioButton=False )
# Result: ui.SubMenuItem('window1|menu49|menuItem569') #
pm.menuItem( label='No', radioButton=True )
# Result: ui.SubMenuItem('window1|menu49|menuItem570') #
pm.menuItem( divider=True )
# Result: ui.SubMenuItem('window1|menu49|menuItem571') #
pm.menuItem( label='Top', checkBox=True )
# Result: ui.SubMenuItem('window1|menu49|menuItem572') #
pm.menuItem( label='Middle', checkBox=False )
# Result: ui.SubMenuItem('window1|menu49|menuItem573') #
pm.menuItem( label='Bottom', checkBox=True )
# Result: ui.SubMenuItem('window1|menu49|menuItem574') #
pm.menuItem( divider=True )
# Result: ui.SubMenuItem('window1|menu49|menuItem575') #
pm.menuItem( label='Option' )
# Result: ui.SubMenuItem('window1|menu49|menuItem576') #
pm.menuItem( optionBox=True )
# Result: ui.SubMenuItem('window1|menu49|menuItem577') #
pm.columnLayout()
# Result: ui.ColumnLayout('window1|columnLayout61') #
pm.button()
# Result: ui.Button('window1|columnLayout61|button53') #
pm.button()
# Result: ui.Button('window1|columnLayout61|button54') #
pm.button()
# Result: ui.Button('window1|columnLayout61|button55') #
pm.showWindow()

Previous topic

pymel.core.windows.menuEditor

Next topic

pymel.core.windows.menuSet

Core

Core Modules

Other Modules

This Page