pymel.core.windows.popupMenu

popupMenu(*args, **kwargs)

This command creates a popup menu and attaches it to the current control if no parent is specified. The popup menu is posted with the right mouse button by default. Popup menus can be added to any kind of control, however, on some widgets, only the standard menu button (3rd mouse button) can be used to trigger popup menus. This is to meet generally accepted UI guidelines that assign the 3rd mouse button and only this one to popup menus, and also to prevent unexpected behavior of controls like text fields, that expect 1st and 2nd button to be reserved for contextual operations like text or item selection...

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

Indicate whether the menu will be able to support option box menu items. An error results if an option box item is added to a menu that doesn’t allow them. This flag may be queried and must be specified when the popup menu is created. The default value is false.

altModifier (alt) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Specify this flag if the Alt modifier must be pressed when posting the popup menu.
button (b) int ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Indicate which button posts the popup menu. Valid values range from 1 to 3 where 1 is the left most button on the mouse.
ctrlModifier (ctl) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Specify this flag if the Cntl modifier must be pressed when posting the popup menu.
defineTemplate (dt) unicode  
   
deleteAllItems (dai) bool ../../../_images/edit.gif
 
Delete all the items in this menu.Flag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list.
exists (ex) bool  
   
itemArray (ia) bool ../../../_images/query.gif
 
Return string array of the menu item names.
markingMenu (mm) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Set the marking menu state of this popup menu.
numberOfItems (ni) bool ../../../_images/query.gif
 
Return number of items in the menu.
parent (p) unicode  
   
postMenuCommand (pmc) script ../../../_images/create.gif ../../../_images/edit.gif
 
Specify a script to be executed when the popup 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 popup menu is shown.
shiftModifier (sh) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Specify this flag if the Shift modifier must be pressed when posting the popup menu.
useTemplate (ut) unicode  
   

Derived from mel command maya.cmds.popupMenu

Example:

import pymel.core as pm

import maya.cmds as cmds

pm.window()
# Result: ui.Window('window1') #
pm.columnLayout()
# Result: ui.ColumnLayout('window1|columnLayout68') #
pm.button()
# Result: ui.Button('window1|columnLayout68|button64') #
pm.popupMenu()
# Result: ui.PopupMenu('window1|columnLayout68|button64|popupMenu85') #
pm.menuItem()
# Result: ui.CommandMenuItem('window1|columnLayout68|button64|popupMenu85|menuItem876') #
pm.menuItem()
# Result: ui.CommandMenuItem('window1|columnLayout68|button64|popupMenu85|menuItem877') #
pm.menuItem()
# Result: ui.CommandMenuItem('window1|columnLayout68|button64|popupMenu85|menuItem878') #
pm.text()
# Result: ui.Text('window1|columnLayout68|text5') #
pm.popupMenu( button=1 )
# Result: ui.PopupMenu('window1|columnLayout68|text5|popupMenu86') #
pm.menuItem()
# Result: ui.CommandMenuItem('window1|columnLayout68|text5|popupMenu86|menuItem879') #
pm.menuItem()
# Result: ui.CommandMenuItem('window1|columnLayout68|text5|popupMenu86|menuItem880') #
pm.menuItem()
# Result: ui.CommandMenuItem('window1|columnLayout68|text5|popupMenu86|menuItem881') #
pm.checkBox( 'aCheckBox' )
# Result: ui.CheckBox('window1|columnLayout68|aCheckBox') #
pm.popupMenu( parent='aCheckBox', alt=True, ctl=True )
# Result: ui.PopupMenu('window1|columnLayout68|aCheckBox|popupMenu87') #
pm.menuItem()
# Result: ui.CommandMenuItem('window1|columnLayout68|aCheckBox|popupMenu87|menuItem882') #
pm.menuItem()
# Result: ui.CommandMenuItem('window1|columnLayout68|aCheckBox|popupMenu87|menuItem883') #
pm.menuItem()
# Result: ui.CommandMenuItem('window1|columnLayout68|aCheckBox|popupMenu87|menuItem884') #
pm.showWindow()

Previous topic

pymel.core.windows.picture

Next topic

pymel.core.windows.progressBar

Core

Core Modules

Other Modules

This Page