• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python cmds.shelfLayout函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: shelfLayoutOnly

 def shelfLayoutOnly(self):
     dirfileList = dirListFilePath( self.psePath )
     for item in dirfileList:
         mc.shelfLayout(item, cwh=(188, 196))
         self.iconButton( item )
         mc.setParent('mainShelfTab')
         mc.setParent('..')
开发者ID:chuckbruno,项目名称:Python_scripts,代码行数:7,代码来源:poseMachine_01.py


示例2: buildMainLayout

 def buildMainLayout(self):
     '''Build the main part of the ui
     '''
     
     tabs = mc.tabLayout()
     tab1 = mc.columnLayout(adj=True)
     
     mc.scrollLayout(cr=True)
     self.shelfLayout = mc.shelfLayout()
     
     self.refreshShelfLayout()
     
     mc.setParent(tabs)
     
     tab2 = mc.columnLayout(adj=True)
 
     mc.separator(height=8, style='none')
     mc.text('Select curve(s) to export. Multiple selected curves will be combined.')
     mc.text('Center and fit the curve in the viewport,')
     mc.text('and make sure nothing else is visible for best icon creation.')
     mc.separator(height=16, style='in')
     
     mc.button('Export Selected Curve', command=self.exportControl, annotation='Select a nurbsCurve to export.')
     
     mc.tabLayout( tabs, edit=True, tabLabel=((tab1, 'Import'), 
                                              (tab2, 'Export')
                                              ))
     
     if not mc.shelfLayout(self.shelfLayout, query=True, numberOfChildren=True):
         mc.tabLayout( tabs, edit=True, selectTab=tab2)
开发者ID:Italic-,项目名称:maya-prefs,代码行数:30,代码来源:ml_controlLibrary.py


示例3: create_shelf

def create_shelf():
    """
    Create the OBB shelf

    Raises:
        None

    Returns:
        None
    """

    tab_layout = mel.eval('$pytmp=$gShelfTopLevel')
    shelf_exists = cmds.shelfLayout('OBB', exists=True)

    if shelf_exists:
        cmds.deleteUI('OBB', layout=True)

    shelf = cmds.shelfLayout('OBB', parent=tab_layout)

    for button, kwargs in buttons.items():

        img = QtGui.QImage(kwargs['image'])
        kwargs['width'] = img.width()
        kwargs['height'] = img.height()

        cmds.shelfButton(label=button, parent=shelf, **kwargs)

    # Fix object 0 error.
    shelves = cmds.shelfTabLayout(tab_layout, query=True, tabLabelIndex=True)

    for index, shelf in enumerate(shelves):
        cmds.optionVar(stringValue=("shelfName%d" % (index+1), str(shelf)))
开发者ID:matthewkapfhammer,项目名称:OBB,代码行数:32,代码来源:__init__.py


示例4: Newtab

def Newtab(*args):
    sel_tab = mc.shelfTabLayout('tabs',q=1,st=1)
    crnt_tab= mc.shelfTabLayout(sel_tab,q=1,ca=1)
    Newtab = mc.promptDialog(
                    title='Create New Tab',
                    message='New Tab Name:',
                    button=['OK', 'Cancel'],
                    defaultButton='OK',
                    cancelButton='Cancel',
                    dismissString='Cancel')    
    if Newtab == 'OK':
        n_text = mc.promptDialog(query=True, text=True)
        if n_text == '':
            mc.confirmDialog (title='Error' ,message= 'Sorry, The name entered is not valid', button=['OK'] ,defaultButton='Yes')      
        else:
            if crnt_tab:
                for each in crnt_tab:
                    if each == n_text:
                        mc.confirmDialog (title='Error' ,message= 'Sorry, The name entered is already exists', button=['OK'] ,defaultButton='Yes')
                        return 
            #else:     
            if sel_tab == 'Animation':
                Nw_tab=savepathini+'Savepose/Animation/'+n_text+'/'
                mc.shelfLayout(n_text,w=450,h=200,bgc=(0.3,0.3,0.3),p=Animation)
                mc.sysFile(Nw_tab, makeDir=True )
                     
            else:
                mc.shelfLayout(n_text,w=450,h=200,bgc=(0.3,0.3,0.3),p=Poses)
                Nw_tab=savepathini+'Savepose/Poses/'+n_text+'/' 
                mc.sysFile(Nw_tab, makeDir=True )
            mc.shelfTabLayout(sel_tab,e=1,st=n_text)
开发者ID:sid2364,项目名称:Maya_Python,代码行数:31,代码来源:SR_AnimPoseLib.py


示例5: updateShelf

 def updateShelf(self, *args):
     try:
         allNewShelfTab = self.loadShelfAll()
         for item in allNewShelfTab:
             cmds.shelfLayout( '%s'%item, cwh=(35, 35), p='mainShelfTab' )
             newShelf = self.readShelf(item)
             mm.eval(newShelf)
     except:pass
开发者ID:chuckbruno,项目名称:Python_scripts,代码行数:8,代码来源:speedToolsJJ.py


示例6: shelfLayoutOnly

 def shelfLayoutOnly(self):
     import maya.cmds as mc
     dirfileList = dirListFilePath( self.psePath )
     for item in dirfileList:
         mc.shelfLayout(item, cwh=(188, 196), p='mainMeShelfTab')
         self.iconButton( item )
         mc.setParent('mainMeShelfTab')
         mc.setParent('..')
开发者ID:chuckbruno,项目名称:Python_scripts,代码行数:8,代码来源:poseMachine_03.py


示例7: createMyShelf

def createMyShelf():
    # sample code
    shelfName = 'My_Shelf'
    test = cmds.shelfLayout(shelfName, ex=True)
    if test:
        # If the shelf already exists, clear the contents and re-add the
        # buttons.
        newShelf = shelfName
        buttons = cmds.shelfLayout(newShelf, query=True, childArray=True)
        cmds.deleteUI(buttons, control=True)
    else:
        newShelf = mel.eval('addNewShelfTab %s' % shelfName)
        cmds.setParent(newShelf)
开发者ID:boochos,项目名称:work,代码行数:13,代码来源:webrShelf.py


示例8: shelf

def shelf() :
    
    ''' Creates a peelMocapTools shelf '''

    import maya.cmds as m
    import maya.mel as mel

    shelfTabName = "peelMocapTools"
    if not m.shelfLayout(shelfTabName, exists=True) :
       shelfTab = mel.eval("addNewShelfTab(\"%s\")" % shelfTabName)
        
    topShelf = mel.eval("global string $gShelfTopLevel; string $x = $gShelfTopLevel")
    try :
       toolShelf = m.shelfLayout("%s|%s" % (topShelf, shelfTabName), q=True, ca=True)
       if toolShelf is not None :
          if len(toolShelf) > 0 : m.deleteUI(toolShelf)
    except RuntimeError :
       x = 0

    kt = 'import mocapCleanup.keyTools as kt;kt.'
    mx = 'import mocapCleanup.mocap as mx;mx.'
    ms = 'import mocapCleanup.markerset as mz;mz.'
    la = 'import mocapCleanup.labeler as la;la.'
    ld = 'import mocapCleanup.loader as ld;ld.'
    ca = 'import mocapCleanup.camera as ca;ca.'
    
    buttons = [
      [ "Load c3d",             mx + "loadc3d()",            "mocap_loadc3d.bmp" ],
      [ "Data",                 ld + "show()",                "mocap_data.bmp"    ],
      [ "Gui",                  la + "show()",               "mocap_gui.bmp"     ],
      [ "Fill",                 kt + "fill()",               "mocap_fill.bmp"    ],
      [ "Split Parts",          kt + "splitParts()",         "mocap_splitParts.bmp" ],
      [ "Swap Selected",        kt + "swap()",               "mocap_swapSelected.bmp" ],
      [ "Swap All",             kt + "swapAll()",            "mocap_swapAll.bmp" ],
      [ "Extract Before",       kt + "extractBefore()",      "mocap_extractBefore.bmp" ],
      [ "Extract After",        kt + "extractAfter()",       "mocap_extractAfter.bmp" ],
      [ "Extract After Sel",    kt + "extractSelected()",    "mocap_extractSelected.bmp" ],
      [ "Set Current",          kt + "setCurrent('1')",      "mocap_setX.bmp" ],
      [ "Move to Current",      kt + "moveToCurrent('1')",   "mocap_moveToX.bmp" ],
      [ "Move 1 to 2",          kt + "moveFirstToSecond()",  "mocap_moveFirstToSecond.bmp" ],
      [ "Key Current to match", kt + "keyCurrentToMatch()",  "mocap_keyCurrentToMatch.bmp" ],
      [ "Go to next gap",       kt + "goToNextGap()",        "mocap_goToNextGap.bmp" ],
      [ "Toggle Active",        kt + "toggleConnectVis()",   "mocap_eye.bmp" ],
      [ "Camera On",            ca + "rigidbodyCam()",       "mocap_cam_on.bmp" ],
      [ "Camera Off",           ca + "clear()",              "mocap_cam_off.bmp" ],
    ]
    #  [ "Load web data",   "import loader\nx=loader.Loader()\nx.show()", "mocap_c3d.bmp" ],
    #  [ "Import Cameras",  "import camera\ncamera.importCameras()\n", "mocap_cam.bmp" ],
      
    for i in buttons :
      m.shelfButton(l=i[0], stp="python", c=i[1], i1=i[2], p=shelfTabName)
开发者ID:mocap-ca,项目名称:cleanup,代码行数:51,代码来源:__init__.py


示例9: createShelf

def createShelf():
    # delete the shelf is already exists
    if cmds.shelfLayout('dmptools', ex=True):
        fullname = cmds.shelfLayout('dmptools', fpn=True, q=True)
        cmds.deleteUI(fullname)
    # create the shelf
    shelfParent = cmds.shelfTabLayout('ShelfLayout', fpn=True, q=True)
    cmds.shelfLayout('dmptools', p=shelfParent)
    # create shelf buttons
    for button in BUTTONS:
        b = addButton(button)
    # select the last created shelf 
    i = cmds.shelfTabLayout(shelfParent, numberOfChildren=True, q=True)
    cmds.shelfTabLayout(shelfParent, selectTabIndex=i, e=True)
开发者ID:manymax21,项目名称:dmptools,代码行数:14,代码来源:dmptoolsShelf.py


示例10: speedWindow

 def speedWindow(self):
     if mc.windowPref('facialWin', exists=1):
         mc.windowPref('facialWin', remove=1)
     if mc.window('facialWin', exists=1):
         mc.deleteUI('facialWin')
     mc.window('facialWin', t='Mudan_FacialPanel', w=960, h=430)
     mc.shelfTabLayout('mainShelfTab', image='smallTrash.png', imageVisible=1)
     mc.shelfLayout('Flower', cwh=(188, 196))
     self.shelfButtonFlower()
     mc.setParent('..')
     mc.shelfLayout('Human', cwh=(188, 196))
     self.shelfButtonHuman()
     mc.setParent('..')
     mc.showWindow()
开发者ID:chuckbruno,项目名称:Python_scripts,代码行数:14,代码来源:facialPanel.py


示例11: getShelfButtonsWithTag

def getShelfButtonsWithTag( tag ):
	buttons = []
	shelves = cmd.lsUI( cl=True, type='shelfLayout' ) or []
	for shelf in shelves:
		if not cmd.shelfLayout( shelf, ex=True ):
			continue

		shelfButtons = cmd.shelfLayout( shelf, q=True, ca=True ) or []
		for button in shelfButtons:
			if cmd.control( button , ex=True ):
				if control( button, q=True, docTag=True ) == buttonTag:
					buttons.append( button )

	return buttons
开发者ID:GuidoPollini,项目名称:MuTools,代码行数:14,代码来源:triggeredUI.py


示例12: create

def create():

    if cmds.shelfLayout(shelf_name, exists=True, q=True):
        cmds.deleteUI(shelf_name)
    
    cmds.setParent(main_shelf_parent)
    cmds.shelfLayout(shelf_name)

    populate_shelf(shelf_name, button_list)

    # fix stupid maya error with shelves generated via python
    top_level_shelf = mel.eval('string $m = $gShelfTopLevel')
    shelves = cmds.shelfTabLayout(top_level_shelf, query=True, tabLabelIndex=True)
    for index, shelf in enumerate(shelves):
        cmds.optionVar(stringValue=('shelfName%d' % (index+1), str(shelf)))
开发者ID:jonathantopf,项目名称:mayaseed,代码行数:15,代码来源:ms_shelf.py


示例13: refreshShelfLayout

 def refreshShelfLayout(self, *args):
     '''Delete and the shelf buttons and remake them
     '''
     
     shelfButtons = mc.shelfLayout(self.shelfLayout, query=True, childArray=True)
     if shelfButtons:
         for child in shelfButtons:
             mc.deleteUI(child)
     
     mc.setParent(self.shelfLayout)
     
     for each in os.listdir(REPOSITORY_PATH):
         if each.endswith('.ctrl'):
             name = os.path.splitext(each)[0]
             icon = None
             imageFile = os.path.join(REPOSITORY_PATH,name+'.png')
             if os.path.isfile(imageFile):
                 icon = imageFile
             filename = os.path.join(REPOSITORY_PATH,each)
             button = mc.shelfButton(command=partial(importControl, name),
                                     image=icon, 
                                     width=70,
                                     height=70,
                                     imageOverlayLabel=name.replace('_',' ').replace('  ',' '),
                                     annotation=name)
             
             menus = mc.shelfButton(button, query=True, popupMenuArray=True)
             if menus:
                 for menu in menus:
                     mc.deleteUI(menu)
开发者ID:Italic-,项目名称:maya-prefs,代码行数:30,代码来源:ml_controlLibrary.py


示例14: openTool

def openTool():
    window = cmds.window('Copymation Toolset', tb=False, s=False)

    #cmds.windowPref('Copymation_Toolset', ra=True)
    shelf = cmds.shelfLayout()

    button = cmds.shelfButton(annotation='Clone animation', image1='animCopymationClone.png', command='animCopymation.clone()', imageOverlayLabel='clone')

    cmds.shelfButton(annotation="Open advanced copy tool",
        image1="redo.png", command="", imageOverlayLabel="copy",
        overlayLabelColor=(1, 1, .25), overlayLabelBackColor=(.15, .9, .1, .4))

    cmds.shelfButton(annotation="Open animation cycler tool",
        image1="undo.png", command="", imageOverlayLabel="cycler",
        overlayLabelColor=(1, .25, .25))

    cmds.shelfButton(annotation="Close Copymation toolset",
        image1="close.png", command='maya.utils.executeDeferred("cmds.deleteUI(\'Copymation_Toolset\')")' , imageOverlayLabel="close",
        overlayLabelColor=(1, .25, .25))

    #resize toolset
    buttonH = cmds.shelfButton(button, q=True, h=True)
    buttonW = cmds.shelfButton(button, q=True, w=True)
    cmds.window(window, edit=True, widthHeight=(buttonW*4+10, buttonH+10))

    #show UI
    showUI()
开发者ID:studiocoop,项目名称:maya-coop,代码行数:27,代码来源:animCopymation.py


示例15: writeShelf

 def writeShelf(self, *args):
     tip = u'\u606d\u559c\uff0c\u5df2\u6210\u529f\u4fdd\u5b58\uff0c\u672c\u9762\u677f\u4f1a\u7ee7\u7eed\u597d\u597d\u670d\u52a1\u7684'
     reload(sys)
     sys.setdefaultencoding('utf-8')
     allShelfButtons = []
     children = cmds.shelfLayout('Tools', q=1, ca=1)
     children.pop(0)
     numS = len(children)
     j = 1
     for name in children:
             oldLabel = cmds.shelfButton(name, q=1, l=1)
             oldImage = cmds.shelfButton(name, q=1, i=1)
             oldImage1 = cmds.shelfButton(name, q=1, i1=1)
             #oldCommand = cmds.shelfButton('shelfButton370', q=1, i=1)
             oldCommand = cmds.shelfButton(name, q=1, command=1)
             oldsourceType = cmds.shelfButton(name, q=1, sourceType=1)
             oldsourceOverlayLabel = cmds.shelfButton(name, q=1, imageOverlayLabel=1)
             #oldLabel.decode('gb2312')
             newCommand = self.remainCommand(oldCommand)
             newImage = self.remainImage(oldImage)
             newImage1 = self.remainImage(oldImage1)
             shelfName = "shelfButton_%s"%j
             shelfButtonName = '%s -image "%s" -image1 "%s" -imageOverlayLabel "%s" -command "%s" -sourceType "%s" %s;\n'%('shelfButton', newImage, newImage1, oldsourceOverlayLabel, newCommand, oldsourceType, shelfName)
             allShelfButtons.append(shelfButtonName)
             j = j + 1
             print newCommand
     f = open('%sTools.txt'%self.tempDir, 'w')
     for item in allShelfButtons:
         f.write(item.encode('utf-8'))
     f.close
     mm.eval('print "%s";'%tip)
开发者ID:chuckbruno,项目名称:Python_scripts,代码行数:31,代码来源:speedTools.py


示例16: writeShelf

 def writeShelf(self, shelf):
     reload(sys)
     sys.setdefaultencoding('utf-8')
     self.allShelfButtons = []
     children = cmds.shelfLayout(shelf, q=1, ca=1)
     #children.pop(0)
     #numS = len(children)
     j = 1
     for name in children:
             oldLabel = cmds.shelfButton(name, q=1, l=1)
             oldImage = cmds.shelfButton(name, q=1, i=1)
             oldImage1 = cmds.shelfButton(name, q=1, i1=1)
             #oldCommand = cmds.shelfButton('shelfButton370', q=1, i=1)
             oldCommand = cmds.shelfButton(name, q=1, command=1)
             oldsourceType = cmds.shelfButton(name, q=1, sourceType=1)
             oldsourceOverlayLabel = cmds.shelfButton(name, q=1, imageOverlayLabel=1)
             #oldLabel.decode('gb2312')
             newCommand = self.remainCommand(oldCommand)
             newImage = self.remainImage(oldImage)
             newImage1 = self.remainImage(oldImage1)
             shelfName = "shelfButton_%s_%s"%(j, shelf)
             shelfButtonName = '%s -image "%s" -image1 "%s" -imageOverlayLabel "%s" -command "%s" -sourceType "%s" -p "%s" %s;\n'%('shelfButton', newImage, newImage1, oldsourceOverlayLabel, newCommand, oldsourceType, shelf, shelfName)
             self.allShelfButtons.append(shelfButtonName)
             j += 1
             print newCommand
     f = open('%s%s%s'%(self.tempDir, shelf, '.txt'), 'w')
     for item in self.allShelfButtons:
         f.write(item.encode('utf-8'))
     f.close
     #mm.eval('print "%s";'%tip)
     self.allShelfButtons = []
开发者ID:chuckbruno,项目名称:Python_scripts,代码行数:31,代码来源:speedToolsJJ.py


示例17: delete_shelf

def delete_shelf(shelf_name):
    '''
    Delete maya shelf and update maya shelf optionVars
    :param shelf_name: string: name of the shelf to be deleted
    :return:
    '''
    if mayaIsBatch():
        return
    if not cmds.shelfLayout(shelf_name, q=True, ex=True):
        return

    shelfs = cmds.optionVar(q='numShelves')
    curret_shelf = None

    # Shelf preferences.
    for i in range(shelfs + 1):
        if shelf_name == cmds.optionVar(q="shelfName%i" % i):
            curret_shelf = i
            break

    # manage shelve ids
    for i in range(curret_shelf, shelfs + 1):
        cmds.optionVar(iv=("shelfLoad%s" % str(i), cmds.optionVar(q="shelfLoad%s" % str(i + 1))))
        cmds.optionVar(sv=("shelfName%s" % str(i), cmds.optionVar(q="shelfName%s" % str(i + 1))))
        cmds.optionVar(sv=("shelfFile%s" % str(i), cmds.optionVar(q="shelfFile%s" % str(i + 1))))
        
    cmds.optionVar(remove="shelfLoad%s" % shelfs)
    cmds.optionVar(remove="shelfName%s" % shelfs)
    cmds.optionVar(remove="shelfFile%s" % shelfs)
    cmds.optionVar(iv=("numShelves", shelfs - 1))

    cmds.deleteUI(shelf_name, layout=True)
    mel.eval("shelfTabChange")
    log.info('Shelf deleted: % s' % shelf_name)
开发者ID:oglops,项目名称:Red9_StudioPack,代码行数:34,代码来源:setup.py


示例18: handPose_fromSelect_toShelf

def handPose_fromSelect_toShelf():
    _shelfName = 'pose_Hand'
    if not cmds.shelfLayout( _shelfName, q=True, exists=True):
         mel.eval('addNewShelfTab "%s";'%_shelfName)

         _cmd  ='\n'
         _cmd +='import maya.cmds as cmds\n'
         _cmd +='import sys\n'
         _cmd +='\n'
         _cmd +=u'# 파이썬 경로 추가\n'
         _cmd +='_newPath = \'//alfredstorage/Alfred_asset/Maya_Shared_Environment/scripts_Python/Alfred_AssetTools\'\n'
         _cmd +='if not _newPath in sys.path:\n'
         _cmd +='    sys.path.append(_newPath)\n'
         _cmd +='\n'
         _cmd +=u'# UI Load\n'
         _cmd +='import Alfred_AssetTools\n'
         _cmd +='reload(Alfred_AssetTools)\n'
         _cmd +=__name__+'.handPose_fromSelect_toShelf()\n'
         
         cmds.shelfButton(
            commandRepeatable = True ,
            image1            = 'pythonFamily.png' ,
            label             = 'getHandPose',
            annotation        = 'getHandPose from Selection',
            sourceType        = 'python',
            command           = _cmd ,
            imageOverlayLabel = 'getHandPose',
            parent            = _shelfName,
            )

    _cmd = getData_from_selection()
    if not _cmd:
        return
    
    _result = cmds.promptDialog(
        title='name',
        message='pose name:',
        button=['OK', 'Cancel'],
        defaultButton='OK',
        cancelButton='Cancel',
        dismissString='Cancel'
        )
    if _result != 'OK':
        print _cmd
        return

    _label = cmds.promptDialog(query=True, text=True)
    
    cmds.shelfButton(
        commandRepeatable =True ,
        image1            ='commandButton.png' ,
        label             ='handPose_'+_label ,
        annotation        ='handPose_'+_label ,
        sourceType        ='mel',
        command           = _cmd ,
        imageOverlayLabel =_label,
        parent            =_shelfName,
    )
开发者ID:kyuhoChoi,项目名称:mayaTools,代码行数:58,代码来源:Gun_Tools.py


示例19: create_shelf

def create_shelf():
    '''Create the mtoatools shelf'''

    tab_layout = mel.eval('$pytmp=$gShelfTopLevel')
    shelf_exists = cmds.shelfLayout('mtoatools', exists=True)

    if shelf_exists:
        cmds.deleteUI('mtoatools', layout=True)

    shelf = cmds.shelfLayout('mtoatools', parent=tab_layout)

    for button, kwargs in buttons.items():

        img = QtGui.QImage(kwargs['image'])
        kwargs['width'] = img.width()
        kwargs['height'] = img.height()

        cmds.shelfButton(label=button, parent=shelf, **kwargs)
开发者ID:danbradham,项目名称:mtoatools,代码行数:18,代码来源:__init__.py


示例20: initializePlugin

def initializePlugin(mobject):
    """Initialization method for Maya Autodesk plugin system; creates new shelf and registers each command."""

    # make sure the plug-in path is actually found by the python interpreter
    if (not len([p for p in sys.path if re.search('plug-ins', p)])):
        if (sys.platform == "linux" or sys.platform == "linux2"):
            sys.path.append([p for p in sys.path if re.search('bin$', p)][0] + '/plug-ins')
        else:
            sys.path.append([p for p in sys.path if re.search('bin$', p)][0] + '\\plug-ins')

    # import all sub-modules from directory 'pk_src' (print to console in case of error)
    for cmd in kPluginCmdName:
        try:
            exec('from pk_src import ' + cmd)
        except:
            sys.stderr.write("Could not find module 'pk_src.%s'\n" % cmd)
    # force reload of modules to avoid having maya to restart every time a class definition changes
    for cmd in kPluginCmdName:
        try:
            reload(sys.modules["pk_src." + cmd])
        except:
            sys.stderr.write("Error reloading " + cmd)
    # get maya plugin module
    mplugin = OpenMayaMPx.MFnPlugin(mobject)
    mplugin.setVersion(pk_version)
    # get top level shelf to create new shelf layout where each command gets its own button to execute command
    topShelf = mel.eval('$nul = $gShelfTopLevel')
    # check if old reference still exists and delete it
    if (cmds.shelfLayout("ProKlaue", exists = 1)):
        cmds.deleteUI("ProKlaue", lay = 1)
    # create new shelf layout proKlaue
    proKlaue = cmds.shelfLayout("ProKlaue", parent = topShelf)
    # maya messes up the shelf optionVars shelfName1 --> recreate shelf names
    shelves = cmds.shelfTabLayout(topShelf, query=True, tabLabelIndex=True)
    for index, shelf in enumerate(shelves):
        cmds.optionVar(stringValue=("shelfName%d" % (index+1), str(shelf)))

    # register commands and add buttons to shelf
    for cmd in kPluginCmdName:
        try:
            mplugin.registerCommand( cmd, eval(cmd + "." + cmd + "Creator"), eval(cmd + "." + cmd + "SyntaxCreator") )
            exec(cmd + ".addButton('%s')" %(proKlaue))
        except:
            sys.stderr.write("Failed to register command or to add shelf button: %s\n" % cmd)
开发者ID:EnReich,项目名称:ProKlaue,代码行数:44,代码来源:proKlaue.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python cmds.showHelp函数代码示例发布时间:2022-05-27
下一篇:
Python cmds.shelfButton函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap