本文整理汇总了Python中maya.cmds.shelfLayout函数的典型用法代码示例。如果您正苦于以下问题:Python shelfLayout函数的具体用法?Python shelfLayout怎么用?Python shelfLayout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shelfLayout函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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('..')
示例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)
示例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)))
示例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)
示例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
示例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('..')
示例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)
示例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)
示例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)
示例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()
示例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
示例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)))
示例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)
示例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()
示例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)