本文整理汇总了Python中maya.cmds.shelfLayout方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.shelfLayout方法的具体用法?Python cmds.shelfLayout怎么用?Python cmds.shelfLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类maya.cmds
的用法示例。
在下文中一共展示了cmds.shelfLayout方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: shelf
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import shelfLayout [as 别名]
def shelf():
"""
Add a new shelf in Maya with all the tools that are provided in the
SHELF_TOOLS variable. If the tab exists it will be deleted and re-created
from scratch.
"""
# get top shelf
gShelfTopLevel = mel.eval("$tmpVar=$gShelfTopLevel")
# get top shelf names
shelves = cmds.tabLayout(gShelfTopLevel, query=1, ca=1)
# delete shelf if it exists
if SHELF_NAME in shelves:
cmds.deleteUI(SHELF_NAME)
# create shelf
cmds.shelfLayout(SHELF_NAME, parent=gShelfTopLevel)
# add modules
for tool in SHELF_TOOLS:
if tool.get("image1"):
cmds.shelfButton(style="iconOnly", parent=SHELF_NAME, **tool)
else:
cmds.shelfButton(style="textOnly", parent=SHELF_NAME, **tool)
示例2: shelf
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import shelfLayout [as 别名]
def shelf():
"""
Add a new shelf in Maya with the tools that is provided in the SHELF_TOOL
variable. If the tab exists it will be checked to see if the button is
already added. If this is the case the previous button will be deleted and
a new one will be created in its place.
"""
# get top shelf
gShelfTopLevel = mel.eval("$tmpVar=$gShelfTopLevel")
# get top shelf names
shelves = cmds.tabLayout(gShelfTopLevel, query=1, ca=1)
# create shelf
if SHELF_NAME not in shelves:
cmds.shelfLayout(SHELF_NAME, parent=gShelfTopLevel)
# get existing members
names = cmds.shelfLayout(SHELF_NAME, query=True, childArray=True) or []
labels = [cmds.shelfButton(n, query=True, label=True) for n in names]
# delete existing button
if SHELF_TOOL.get("label") in labels:
index = labels.index(SHELF_TOOL.get("label"))
cmds.deleteUI(names[index])
# add button
cmds.shelfButton(style="iconOnly", parent=SHELF_NAME, **SHELF_TOOL)
示例3: get
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import shelfLayout [as 别名]
def get(cls, name, layout=None):
if not layout:
layout = cls.top_level_layout()
cmds.setParent(layout)
shelf = cmds.shelfLayout(name, q=True, exists=True)
if shelf:
return cls(name, layout)
else:
raise NameError("Unable to find shelf: " + name)
# -------------------------------------------------------------------------
示例4: create
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import shelfLayout [as 别名]
def create(self):
cmds.setParent(self.layout)
cmds.shelfLayout(self.name)
self._shelf_error_fix()
# -------------------------------------------------------------------------
示例5: exists
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import shelfLayout [as 别名]
def exists(self):
cmds.setParent(self.layout)
return cmds.shelfLayout(self.name, q=True, exists=True)
# -------------------------------------------------------------------------
示例6: buildMainLayout
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import shelfLayout [as 别名]
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)
示例7: refreshShelfLayout
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import shelfLayout [as 别名]
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)
#mc.popupMenu()
#mc.menuItem('delete', command=partial(self.deleteShelfButton, name))