当前位置: 首页>>代码示例>>Python>>正文


Python cmds.menu方法代码示例

本文整理汇总了Python中maya.cmds.menu方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.menu方法的具体用法?Python cmds.menu怎么用?Python cmds.menu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.menu方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: install

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def install():
    """Install Maya-specific functionality of avalon-core.

    This function is called automatically on calling `api.install(maya)`.

    """

    # Inherit globally set name
    self._menu = api.Session["AVALON_LABEL"] + "menu"

    _register_callbacks()
    _register_events()
    _set_project()

    # Check if maya version is compatible else fix it, Maya2018 only
    # Should be run regardless of batch mode
    compat.install()

    if not IS_HEADLESS:
        _install_menu()

    pyblish.register_host("mayabatch")
    pyblish.register_host("mayapy")
    pyblish.register_host("maya") 
开发者ID:getavalon,项目名称:core,代码行数:26,代码来源:pipeline.py

示例2: run

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def run(*args, **kwargs):  # @UnusedVariable
    """ Menu run execution

    Args:
        *args: Variable length argument list.
        **kwargs: Arbitrary keyword arguments.
    """

    # get check-box state
    state = args[0]

    if state:
        cmds.optionVar(intValue=("mgear_dag_menu_OV", 1))
    else:
        cmds.optionVar(intValue=("mgear_dag_menu_OV", 0))

    # runs dag menu right click mgear's override
    mgear_dagmenu_toggle(state) 
开发者ID:mgear-dev,项目名称:mgear_core,代码行数:20,代码来源:dagmenu.py

示例3: initializeMenu

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def initializeMenu(self, entries):
        try:
            # gMainWindow = MayaInterop.main_parent_window()
            gMainWindow = maya.mel.eval('$temp1=$gMainWindow')
        except RuntimeError as e:
            print e
            print 'Are you running in Batch Python?'
            gMainWindow = None

        try:
            print 'Initialising menu...'
            self.perforceMenu = cmds.menu("PerforceMenu", parent=gMainWindow, tearOff=True, label='Perforce')
            cmds.setParent(self.perforceMenu, menu=True)
        except RuntimeError as e:
            print 'Maya error while trying to create menu:',
            print e 
开发者ID:TomMinor,项目名称:P4VFX,代码行数:18,代码来源:interop.py

示例4: buttonWithPopup

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def buttonWithPopup(self, label=None, command=None, annotation='', shelfLabel='', shelfIcon='render_useBackground', readUI_toArgs={}):
        '''
        Create a button and attach a popup menu to a control with options to create a shelf button or a hotkey.
        The argCommand should return a kwargs dictionary that can be used as args for the main command.
        '''

        if self.icon:
            shelfIcon = self.icon

        if annotation and not annotation.endswith('.'):
            annotation+='.'

        button = mc.button(label=label, command=command, annotation=annotation+' Or right click for more options.')

        mc.popupMenu()
        self.shelfMenuItem(command=command, annotation=annotation, shelfLabel=shelfLabel, shelfIcon=shelfIcon)
        self.hotkeyMenuItem(command=command, annotation=annotation)
        return button 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:20,代码来源:ml_utilities.py

示例5: _uninstall_menu

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def _uninstall_menu():

    # In Maya 2020+ don't use the QApplication.instance()
    # during startup (userSetup.py) as it will return a
    # QtCore.QCoreApplication instance which does not have
    # the allWidgets method. As such, we call the staticmethod.
    all_widgets = QtWidgets.QApplication.allWidgets()

    widgets = dict((w.objectName(), w) for w in all_widgets)
    menu = widgets.get(self._menu)

    if menu:
        menu.deleteLater()
        del(menu) 
开发者ID:getavalon,项目名称:core,代码行数:16,代码来源:pipeline.py

示例6: _update_menu_task_label

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def _update_menu_task_label():
    """Update the task label in Avalon menu to current session"""

    if IS_HEADLESS:
        return

    object_name = "{}|currentContext".format(self._menu)
    if not cmds.menuItem(object_name, query=True, exists=True):
        logger.warning("Can't find menuItem: {}".format(object_name))
        return

    label = "{}, {}".format(api.Session["AVALON_ASSET"],
                            api.Session["AVALON_TASK"])
    cmds.menuItem(object_name, edit=True, label=label) 
开发者ID:getavalon,项目名称:core,代码行数:16,代码来源:pipeline.py

示例7: changeOptionDegree

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def changeOptionDegree(self, degreeOption, *args):
        """ Set optionVar to choosen menu item.
        """
        cmds.optionVar(stringValue=('dpAutoRigLastDegreeOption', degreeOption))
        self.degreeOption = int(degreeOption[0]) 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:7,代码来源:dpAutoRig.py

示例8: get_option_var_state

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def get_option_var_state():
    """ Gets dag menu option variable

    Maya's optionVar command installs a variable that is kept on Maya's
    settings so that you can use it on future sessions.

    Maya's optionVar are a quick and simple way to store a custom variable on
    Maya's settings but beware that they are kept even after mGear's uninstall
    so you will need to run the following commands.

    Returns:
        bool: Whether or not mGear's dag menu override is used

    Example:
        The following removes mgears dag menu optionVar

        .. code-block:: python

           from maya import cmds

           if not cmds.optionVar(exists="mgear_dag_menu_OV"):
               cmds.optionVar(remove="mgear_dag_menu_OV")
    """

    # if there is no optionVar the create one that will live during maya
    # current and following sessions
    if not cmds.optionVar(exists="mgear_dag_menu_OV"):
        cmds.optionVar(intValue=("mgear_dag_menu_OV", 0))

    return cmds.optionVar(query="mgear_dag_menu_OV") 
开发者ID:mgear-dev,项目名称:mgear_core,代码行数:32,代码来源:dagmenu.py

示例9: install

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def install():
    """ Installs dag menu option
    """

    # get state
    state = get_option_var_state()

    cmds.setParent(mgear.menu_id, menu=True)
    cmds.menuItem("mgear_dagmenu_menuitem", label="mGear Viewport Menu ",
                  command=run, checkBox=state)
    cmds.menuItem(divider=True)

    run(state) 
开发者ID:mgear-dev,项目名称:mgear_core,代码行数:15,代码来源:dagmenu.py

示例10: mgear_dagmenu_callback

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def mgear_dagmenu_callback(*args, **kwargs):  # @UnusedVariable
    """ Triggers dag menu display

    If selection is ends with **_ctl** then display mGear's contextual menu.
    Else display Maya's standard right click dag menu

    Args:
        *args: Parent Menu path name / Variable length argument list.
        **kwargs: Arbitrary keyword arguments.

    Returns:
        str: Menu object name/path that is passed to the function
    """

    # cast args into more descend variable name
    parent_menu = args[0]

    # if second argument if not a bool then means that we are running
    # the override
    if type(args[1]) != bool:
        sel = cmds.ls(selection=True, long=True, exactType="transform")
        if sel and cmds.objExists("{}.isCtl".format(sel[0])):
            # cleans menu
            _parent_menu = parent_menu.replace('"', '')
            cmds.menu(_parent_menu, edit=True, deleteAllItems=True)

            # fills menu
            mgear_dagmenu_fill(_parent_menu, sel[0])
        else:
            mel.eval("buildObjectMenuItemsNow " + parent_menu)

    # always return parent menu path
    return parent_menu 
开发者ID:mgear-dev,项目名称:mgear_core,代码行数:35,代码来源:dagmenu.py

示例11: removeMenu

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def removeMenu(menuName=kPluginCmdName):
    """remove menu when plugin unload"""
    if cmds.menu(menuName, q=True, exists=True):
        cmds.deleteUI(menuName, menu=True) 
开发者ID:WendyAndAndy,项目名称:MayaDev,代码行数:6,代码来源:pyMyPlugin.py

示例12: makeMenu

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def makeMenu(menuName=kPluginCmdName):
    """make menu when plugin load"""
    removeMenu(menuName)
    topMenu = cmds.menu(menuName, label=menuName, parent=u'MayaWindow', tearOff=True)
    cmds.menuItem(label=kPluginCmdName, parent=topMenu, command=kPluginCmdName, sourceType='mel')


# Plugin class
# ---------------------------------------------------------------------- 
开发者ID:WendyAndAndy,项目名称:MayaDev,代码行数:11,代码来源:pyMyPlugin.py

示例13: initializePlugin

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def initializePlugin(mobject):
    """Initialize the plug-in and add menu"""
    errMsg = u'Failed to register command: %s\n' % kPluginCmdName
    plugin = om.MFnPlugin(mobject, kPluginVendor, kPluginVersion)
    try:
        plugin.registerCommand(kPluginCmdName, MyDemo.creator)
        makeMenu(menuName=kPluginCmdName)
        # makeShelf(shelfName=kPluginCmdName)
    except:
        sys.stderr.write(errMsg)
        raise

# Uninitialize
# ---------------------------------------------------------------------- 
开发者ID:WendyAndAndy,项目名称:MayaDev,代码行数:16,代码来源:pyMyPlugin.py

示例14: uninitializePlugin

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def uninitializePlugin(mobject):
    """Uninitialize the plug-in and delete menu"""
    plugin = om.MFnPlugin(mobject)
    try:
        plugin.deregisterCommand(kPluginCmdName)
        removeMenu(menuName=kPluginCmdName)
        # removeShelf(shelfName=kPluginCmdName)
    except:
        sys.stderr.write('Failed to unregister command: %s\n' % kPluginCmdName)
        raise 
开发者ID:WendyAndAndy,项目名称:MayaDev,代码行数:12,代码来源:pyMyPlugin.py

示例15: createUI

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def createUI():
    cmds.setParent('MayaWindow')
    try:
        cmds.menu('MukaiLab', query = True, label = True)
    except:
        cmds.menu('MukaiLab', label = 'MukaiLab')
    cmds.setParent('MukaiLab', menu = True)
    cmds.menuItem('SSDS', label = 'SSDS', command = showBuildWindow) 
开发者ID:TomohikoMukai,项目名称:ssds,代码行数:10,代码来源:mlSSDS.py


注:本文中的maya.cmds.menu方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。