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


Python cmds.menuItem函数代码示例

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


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

示例1: loadSelectedObj

def loadSelectedObj():
    cmds.file(new=True, pm=False, force=True)
    selected = cmds.optionMenu(loadComponentsMenu, q=True, v=True)
    global furniture
    global furnitureFilePath
    path = os.path.split(furnitureFilePath)[0] + "/meshes/furniture/"
    menuItems = cmds.optionMenu(componentsMenu, q=True, itemListLong=True)
    cmds.textField(objNameInput, tx=selected.split(".")[0].split("/")[1], e=True)
    if menuItems:
        cmds.deleteUI(menuItems)
    for comp in furniture["components"] :
        if comp["src"] == selected :
            global currentComponent
            componentDef = ""

            with open(os.path.split(furnitureFilePath)[0]+"/"+comp["src"], "r") as componentFile:
                componentDef = componentFile.read()
            currentComponent = json.loads(componentDef)

            cmds.file(path + currentComponent["src"], i=True)
            for con in currentComponent["connectors"]: #for connectors in the current objects connectors
                for types in con["componentTypes"]:
                    cmds.menuItem(p=componentsMenu, label=types)
                for jnt in con["out"]:
                    loc = cmds.spaceLocator()
                    cmds.move(jnt["position"][0], jnt["position"][1], jnt["position"][2], loc)
                    cmds.scale(jnt["scale"][0], jnt["scale"][1], jnt["scale"][2], loc)
                    cmds.rotate(jnt["rotation"][0], jnt["rotation"][1], jnt["rotation"][2], loc)
    updateJson()
    selectLocators()
    cmds.textField(typeInput, tx=currentComponent["type"], e=True)
开发者ID:SweetheartSquad,项目名称:Scripts,代码行数:31,代码来源:FurnitureComponentScript.py

示例2: add_button

def add_button(item, parent):
    """ add button to the shelf """

    # create the button itself
    button = cmds.iconTextButton('dmptools_shelf_button_'+item['name'],
                parent=parent,
                enable=True,
                w=35, h=35,
                annotation=item['annotation'],
                image1=item['icon'],
                command=item['command'],
                sourceType='mel')
    # add right click popup items if exists
    if item['menu']:
        # create the popup menu with the name "popup_<name>"
        popMenu = cmds.popupMenu('dmptools_popup_'+item['name'], parent=button, b=3)
        for menuI in item['menuItems']:
            menuI_name = menuI['name']
            # add popup menu items
            if 'divider' in menuI_name:
                # in case it's a divider
                cmds.menuItem('dmptools_popup_item_'+menuI_name, parent=popMenu, divider=True)
            else:
                # in case it's a menu item
                menuI_command = menuI['command']
                cmds.menuItem(parent=popMenu,
                                label=menuI_name,
                                command=menuI_command,
                                sourceType='mel')
开发者ID:jonntd,项目名称:dmptools,代码行数:29,代码来源:shelf.py

示例3: locatorParticlesUI

def locatorParticlesUI():
    """
    """
    # Define window
    locParticleUI = 'locatorParticleWindow'
    if cmds.window(locParticleUI, q=True, ex=True): cmds.deleteUI(locParticleUI)
    locParticleUI = cmds.window(locParticleUI, t='Generate Particles')

    # UI Layout
    cmds.columnLayout(adj=False, cal='left')
    partiTFG = cmds.textFieldGrp('locParticle_particleTFG', label='Particle', text='', cw=[(1, 100)])
    radiusFFG = cmds.floatSliderGrp('locParticle_radiusFSG', label='radius', f=True, min=0.1, max=10.0, fmn=0.01,
                                  fmx=100.0, pre=2, v=1.0, cw=[(1, 100)])
    rotateLocCBG = cmds.checkBoxGrp('locParticle_rotateCBG', label='Add rotatePP', ncb=1, v1=0, cw=[(1, 100)])
    scaleLocCBG = cmds.checkBoxGrp('locParticle_scaleCBG', label='Add scalePP', ncb=1, v1=0, cw=[(1, 100)])
    selfCollideCBG = cmds.checkBoxGrp('locParticle_selfCollideCBG', label='self collide', ncb=1, v1=0, cw=[(1, 100)])

    cmds.button(l='Create Particles', c='glTools.tools.generateParticles.locatorParticlesFromUI()')

    # Popup menu
    cmds.popupMenu(parent=partiTFG)
    for p in cmds.ls(type=['particle', 'nParticle']):
        cmds.menuItem(p, c='cmds.textFieldGrp("' + partiTFG + '",e=True,text="' + p + '")')

    # Show Window
    cmds.showWindow(locParticleUI)
开发者ID:bennymuller,项目名称:glTools,代码行数:26,代码来源:generateParticles.py

示例4: populateMenu

    def populateMenu(self, menu, *args):

        cmds.radioMenuItemCollection(parent=menu)
        for loopOption in self.multiplierValues:
            radioSelected   = (self.multiplier == loopOption["value"])
            option          = loopOption["name"]
            cmds.menuItem (label=utilMod.toTitle(loopOption["name"]), radioButton=radioSelected, command=lambda x, option=option, *args: self.setMultiplier(option),  parent=menu)
开发者ID:Italic-,项目名称:maya-prefs,代码行数:7,代码来源:microTransform.py

示例5: __enter__

    def __enter__(self):
        '''
        Initialize the UI
        '''
        if mc.window(self.name, exists=True):
            mc.deleteUI(self.name)

        mc.window(self.name, title='ml :: '+self.title, iconName=self.title, width=self.width, height=self.height, menuBar=self.menu)
        
        
        if self.menu:
            self.createMenu()
        
        self.form = mc.formLayout()
        self.column = mc.columnLayout(adj=True)

        
        mc.rowLayout( numberOfColumns=2, columnWidth2=(34, self.width-34), adjustableColumn=2, 
                    columnAlign2=('right','left'),
                    columnAttach=[(1, 'both', 0), (2, 'both', 8)] )

        #if we can find an icon, use that, otherwise do the text version
        if self.icon:
            mc.iconTextStaticLabel(style='iconOnly', image1=self.icon)
        else:
            mc.text(label=' _ _ |\n| | | |')
            
        if not self.menu:
            mc.popupMenu(button=1)
            mc.menuItem(label='Help', command=(_showHelpCommand(wikiURL+'#'+self.name)))
        
        mc.text(label=self.info)
        mc.setParent('..')
        mc.separator(height=8, style='single')
        return self
开发者ID:Bumpybox,项目名称:Tapp,代码行数:35,代码来源:ml_utilities.py

示例6: setOptionMenuList

def setOptionMenuList(OMG,itemList,add=False):
	'''
	Set the list of items for the specified optionMenuGrp control
	@param OMG: OptionMenuGrp to set the item list for
	@type OMG: str
	@param itemList: List of items to add to optionMenuGrp
	@type itemList: list
	@param add: Add to existing menu items
	@type add: bool
	'''
	# Check optionMenuGrp
	if not mc.optionMenuGrp(OMG,q=True,ex=True):
		raise UIError('OptionMenu "'+OMG+'" does not exist!')
	
	# Get existing items
	exItemList = mc.optionMenuGrp(OMG,q=True,ill=True)
	
	# Add items
	for item in itemList:
		mc.setParent(OMG)
		mc.menuItem(l=item)
	
	# Remove previous items
	if exItemList:
		for item in exItemList:
			mc.deleteUI(item)
开发者ID:auqeyjf,项目名称:glTools,代码行数:26,代码来源:utils.py

示例7: createMenu

    def createMenu(self,menuDic,menuOrder=None):
        """ Define and draw the window/widget top file menu
        @type  menuDic: dictionary
        @param menuDic: the menu elements, ie entry, callback and submenu
        @type  menuOrder: array
        @param menuOrder: the menu keys oredered
        """        
        
        if menuOrder : 
            lookat = menuOrder
        else :
            lookat = menuDic.keys()
        for mitem in lookat:
            cmds.menu( label=mitem, tearOff=True , parent = self.winName)
            for elem in menuDic[mitem]:            
                if elem["sub"] is not None:
                    elem['id']=cmds.menuItem(subMenu=True, label=elem["name"])
                    for sub in elem['sub'].keys():
                        checkBox = False#elem['sub'][sub]['checkBox']
                        if elem['sub'][sub]["action"] is not None :
                            elem['sub'][sub]['id']=cmds.menuItem( label=elem['sub'][sub]["name"],
#                                                            checkBox=checkBox,
                                                            c=partial(elem['sub'][sub]["action"],sub))
                        else :
                            elem['sub'][sub]['id']=cmds.menuItem( label=elem['sub'][sub]["name"],)
#                                                            checkBox=checkBox,)
#                        if checkBox and elem['sub'][sub].has_key("var"):
#                            cmds.menuItem(elem['sub'][sub]['id'],e=1,checkBox=bool(elem['sub'][sub]['var']))
                    cmds.setParent( '..', menu=True )
                else:
                    if elem["action"] is not None :
                        elem['id']=cmds.menuItem( label=elem["name"],c=elem["action"])
                    else :
                        elem['id']=cmds.menuItem( label=elem["name"])
开发者ID:gj210,项目名称:upy,代码行数:34,代码来源:mayaUI.py

示例8: updateLine

 def updateLine(self, nodeName, metadata, index):
     # Attribute controls will be created with the current metadata content
     result = metadata.split(' ', 2 )
     result += [""] * (3-len(result))
     
     # Attribute Name
     attrNameText = cmds.textField("MtoA_exrMAttributeName", text=result[1])
     cmds.textField(attrNameText, edit=True, changeCommand=pm.Callback(self.changeAttrName, nodeName, attrNameText, index))
     
     # Attribute Type
     menu = cmds.optionMenu("MtoA_exrMAttributeType")
     cmds.menuItem( label='INT', data=0)
     cmds.menuItem( label='FLOAT', data=1)
     cmds.menuItem( label='POINT2', data=2)
     cmds.menuItem( label='MATRIX', data=3)
     cmds.menuItem( label='STRING', data=4)
     if result[0] == 'INT':
         cmds.optionMenu(menu, edit=True, select=1)
     elif result[0] == 'FLOAT':
         cmds.optionMenu(menu, edit=True, select=2)
     elif result[0] == 'POINT2':
         cmds.optionMenu(menu, edit=True, select=3)
     elif result[0] == 'MATRIX':
         cmds.optionMenu(menu, edit=True, select=4)
     elif result[0] == 'STRING':
         cmds.optionMenu(menu, edit=True, select=5)
     cmds.optionMenu(menu, edit=True, changeCommand=pm.Callback(self.changeAttrType, nodeName, menu, index))
     
     # Attribute Value
     attrValueText = cmds.textField("MtoA_exrMAttributeValue", text=result[2])
     cmds.textField(attrValueText, edit=True, changeCommand=pm.Callback(self.changeAttrValue, nodeName, attrValueText, index))
     
     # Remove button
     cmds.symbolButton(image="SP_TrashIcon.png", command=pm.Callback(self.removeAttribute, nodeName, index))
开发者ID:Quazo,项目名称:breakingpoint,代码行数:34,代码来源:customShapeAttributes.py

示例9: ui

    def ui(self, *args):
        """ Check to see if the UI exists """
        windowName = "Window"
        if cmds.window(windowName, exists=True):
            cmds.deleteUI(windowName)

        """ Define width and height variables for buttons and windows"""    
        windowWidth = 120
        windowHeight = 60
        buttonWidth = 100
        buttonHeight = 30

        # Define the main ui window and assign it a key in the UIElements dictinary.
        self.UIElements["window"] = cmds.window(windowName, width=windowWidth, height=windowHeight, title="Example_UI", sizeable=True)
        
        # This is a flow layout.
        self.UIElements["guiFlowLayout1"] = cmds.flowLayout(v=False, width=windowWidth, height=windowHeight, wr=True, bgc=[0.2, 0.2, 0.2])

        # Menu listing all the layout files.
        self.UIElements["keyMenu"] = cmds.optionMenu('layouts', label='Layouts',  p=self.UIElements["guiFlowLayout1"])
        
        # Create a menu item for each json file in the Layout directory.
        for key in self.layout_info['Keys']:  
            cmds.menuItem(label=key, p=self.UIElements["keyMenu"])
        
        """ Show the window"""
        cmds.showWindow(windowName)
开发者ID:OmniZ3D,项目名称:Python-101_Session1_2015,代码行数:27,代码来源:ui_example.py

示例10: ui

def ui():
	'''
	'''
	# Window
	window = 'transformDrivenBlendUI'
	if mc.window(window,q=True,ex=1): mc.deleteUI(window)
	window = mc.window(window,t='Transform Driven Blend')
	
	# Layout
	cl = mc.columnLayout()
	
	# UI Elements
	driveAttrTFG = mc.textFieldGrp('tdb_driveAttrTFG',label='Drive Attr', text='')
	blendShapeTFG = mc.textFieldGrp('tdb_blendShapeTFG',label='BlendShape', text='')
	target1TFG = mc.textFieldGrp('tdb_target1TFG',label='Target 1', text='',cc='glTools.ui.transformDrivenBlend.refreshUI()')
	target2TFG = mc.textFieldGrp('tdb_target2TFG',label='Target 2', text='',cc='glTools.ui.transformDrivenBlend.refreshUI()')
	weight1FFG = mc.floatFieldGrp('tdb_weight1FFG',numberOfFields=1,label='Weight 1',v1=1.0)
	weight2FFG = mc.floatFieldGrp('tdb_weight2FFG',numberOfFields=1,label='Weight 2',v1=-1.0)
	overlapFFG = mc.floatFieldGrp('tdb_overlapFFG',numberOfFields=1,label='Overlap',v1=0.0)
	prefixTFG = mc.textFieldGrp('tdb_prefixTFG',label='Prefix', text='')
	createB = mc.button('tdb_createB',label='Create',c='glTools.ui.transformDrivenBlend.executeFromUI()')
	refreshB = mc.button('tdb_refreshB',label='Refresh',c='glTools.ui.transformDrivenBlend.refreshUI()')
	cancelB = mc.button('tdb_cancelB',label='Cancel',c='mc.deleteUI('+window+')')
	
	# Popup Menus
	mc.popupMenu('tdb_blendShapePUM',p=blendShapeTFG)
	mc.popupMenu('tdb_target1PUM',p=target1TFG)
	mc.popupMenu('tdb_target2PUM',p=target2TFG)
	mc.popupMenu('tdb_driveAttrPUM',p=driveAttrTFG)
	mc.menuItem(label='Set from selected',c='glTools.ui.utils.loadChannelBoxSel("'+driveAttrTFG+'")')
	
	# Show Window
	refreshUI()
	mc.showWindow(window)
开发者ID:auqeyjf,项目名称:glTools,代码行数:34,代码来源:transformDrivenBlend.py

示例11: __init__

    def __init__(s):
        # Build window
        name = "TimelineMarkersMainWindow"
        s.store = Node("Timeline_Markers_Data")

        if cmds.window(name, ex=True):
            cmds.deleteUI(name)
        s.window = cmds.window(name, t="Timeline Markers", rtf=True)

        # Add language changer
        cmds.columnLayout(adj=True)
        s.language_box = cmds.optionMenu(cc=s.build_gui)
        for lang in LANGUAGE:
            cmds.menuItem(l=lang)
        s.outer = cmds.columnLayout(adj=True)
        s.inner = cmds.scrollLayout(cr=True, h=600)

        # Buttons!
        s.current_button = cmds.button(p=s.outer, c=s.add_current)
        s.selected_button = cmds.button(p=s.outer, c=s.add_selected)
        s.save_button = cmds.button(p=s.outer, c=s.save_markers)
        s.load_button = cmds.button(p=s.outer, c=s.load_markers)

        # Lets go!
        s.load_data()
        s.refresh()

        cmds.showWindow(s.window)

        cmds.scriptJob(e=["PostSceneRead", s.load_data], p=s.window)
        cmds.scriptJob(e=["NewSceneOpened", s.load_data], p=s.window)
        cmds.scriptJob(e=["timeChanged", s.update_current], p=s.window)
开发者ID:internetimagery,项目名称:timeline_markers,代码行数:32,代码来源:__init__.py

示例12: createComponent

	def createComponent(self, parentContainer):
		layout = cmds.rowLayout (parent= parentContainer, numberOfColumns = 2)
		cmds.text(parent= layout, l=self.description, align="right", w=150)
		self.selector = cmds.optionMenu(parent= layout, w=350)
		for desc in self.descriptions:
			cmds.menuItem(parent=self.selector, label=desc)
		return layout
开发者ID:bennymuller,项目名称:MayaPythonUI,代码行数:7,代码来源:KeyModifierModule.py

示例13: populate_render_layer_layout

        def populate_render_layer_layout(self, attr):
            if self.render_layer_layout is not None:
                node = attr.split('.')[0]  
                # delete old ui
                children = cmds.columnLayout(self.render_layer_layout, q=True, childArray=True)
                if children is not None:
                    for name in children:
                        cmds.deleteUI(name)

                for i in range(50):
                    i += 1

                    layer_name = 'render_layer_{0}_name'.format(i)

                    if cmds.attributeQuery(layer_name, exists=True, node=node):
                        cmds.setParent(self.render_layer_layout)
                        current_render_layer_layout = cmds.rowLayout(nc=5)
                        for n, width in enumerate(self.render_layer_layout_widths):
                            cmds.rowLayout(current_render_layer_layout, e=True, cw=[n + 1, width])
                        cmds.textField(cc=partial(self.set_render_layer_name, node, i), text=cmds.getAttr('{0}.render_layer_{1}_name'.format(node, i)))
                        entity_type_menu = cmds.optionMenu(cc=partial(self.set_render_layer_type, node, i))
                        for entity_type in ms_commands.RENDER_LAYER_ENTITY_TYPES:
                            cmds.menuItem(label=entity_type)
                        cmds.optionMenu(entity_type_menu, e=True, v=cmds.getAttr('{0}.render_layer_{1}_type'.format(node, i)))
                        pattern_text_field = cmds.textField(cc=partial(self.set_render_layer_pattern, node, i), text=cmds.getAttr('{0}.render_layer_{1}_pattern'.format(node, i)))
                        cmds.textField(cc=partial(self.set_render_layer_order, node, i), text=cmds.getAttr('{0}.render_layer_{1}_order'.format(node, i)))
                        cmds.button(' - ', height=20, command=partial(self.remove_render_layer, node, i))
                
                cmds.setParent(self.render_layer_layout)
                current_render_layer_layout = cmds.rowLayout(nc=2)
                cmds.button(' + ', command=partial(self.add_render_layer, node))
开发者ID:jonathantopf,项目名称:mayaseed,代码行数:31,代码来源:AEms_renderSettingsTemplate.py

示例14: makeRelativeUI

def makeRelativeUI():
	'''
	User Interface for skinCluster.makeRelative()
	'''
	# Window
	win = 'makeRelativeUI'
	if mc.window(win,q=True,ex=True): mc.deleteUI(win)
	win = mc.window(win,t='SkinCluster - Make Relative')
	# Form Layout
	makeRelativeFL = mc.formLayout(numberOfDivisions=100)
	
	# SkinCluster option menu
	skinClusterOMG = mc.optionMenuGrp('makeRelativeSkinClusterOMG',label='SkinCluster')
	for skin in mc.ls(type='skinCluster'): mc.menuItem(label=skin)
	
	# Relative To TextField
	makeRelativeTFB = mc.textFieldButtonGrp('makeRelativeToTFB',label='RelativeTo',text='',buttonLabel='Load Selected')
	
	# Button
	makeRelativeBTN = mc.button(l='Make Relative',c='glTools.ui.skinCluster.makeRelativeFromUI()')
	
	# UI Callbacks
	mc.textFieldButtonGrp(makeRelativeTFB,e=True,bc='glTools.ui.utils.loadTypeSel("'+makeRelativeTFB+'","transform")')
	
	# Form Layout - MAIN
	mc.formLayout(makeRelativeFL,e=True,af=[(skinClusterOMG,'left',5),(skinClusterOMG,'top',5),(skinClusterOMG,'right',5)])
	mc.formLayout(makeRelativeFL,e=True,af=[(makeRelativeTFB,'left',5),(makeRelativeTFB,'right',5)])
	mc.formLayout(makeRelativeFL,e=True,ac=[(makeRelativeTFB,'top',5,skinClusterOMG)])
	mc.formLayout(makeRelativeFL,e=True,af=[(makeRelativeBTN,'left',5),(makeRelativeBTN,'right',5),(makeRelativeBTN,'bottom',5)])
	mc.formLayout(makeRelativeFL,e=True,ac=[(makeRelativeBTN,'top',5,makeRelativeTFB)])
	
	# Open window
	mc.showWindow(win)
开发者ID:RiggingDojoAdmin,项目名称:glTools,代码行数:33,代码来源:skinCluster.py

示例15: __init__

    def __init__(self, *args):
        print 'In RDojo_UI'
        mi = cmds.window('MayaWindow', ma=True, q=True)
        for m in mi:
            if m == 'RDojo_Menu':
                cmds.deleteUI('RDojo_Menu', m=True)
 
        mymenu = cmds.menu('RDojo_Menu', label='RDMenu', to=True, p='MayaWindow')
        cmds.menuItem(label='Rig Tool', parent=mymenu, command=self.ui)

        """ Create a dictionary to store UI elements.
        This will allow us to access these elements later. """
        self.UIElements = {}

        """ This dictionary will store data from the lyout.json files """
        self.layout_info = {}

        """ Call the internal method loadLayoutDefinitions()
            The loadLayoutDefinitions method will read all the json files
            in the layout folder.  Then it will store the data
            in self.part_info.  Remember that we use self when
            calling a method of the class we are in."""

        self.loadLayoutDefinitions()

        # This dictionary will store all of the available rigging modules.
        self.rigmodlst = os.listdir(os.environ["RDOJO"] + 'Modules/Rigging/')
开发者ID:OmniZ3D,项目名称:Python-101_Session1_2015,代码行数:27,代码来源:rdojo_ui.py


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