本文整理汇总了Python中maya.cmds.shelfButton方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.shelfButton方法的具体用法?Python cmds.shelfButton怎么用?Python cmds.shelfButton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类maya.cmds
的用法示例。
在下文中一共展示了cmds.shelfButton方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: shelf
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import shelfButton [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 shelfButton [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: add_button
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import shelfButton [as 别名]
def add_button(self, **kwargs):
import sys
# intercept/adjust some of the arguments
for (key, val) in kwargs.iteritems():
# get full image path
if key.startswith("image") and IconFactory.is_icon_path(val):
kwargs[key] = self.icon_factory.disk_path(val)
cmds.setParent("|".join([self.layout, self.name]))
cmds.shelfButton(**kwargs)
# -------------------------------------------------------------------------
示例4: refreshShelfLayout
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import shelfButton [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))
示例5: createShelfButton
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import shelfButton [as 别名]
def createShelfButton(command, label='', name=None, description='',
image=None, #the default image is a circle
labelColor=(1, 0.5, 0),
labelBackgroundColor=(0, 0, 0, 0.5),
backgroundColor=None
):
'''
Create a shelf button for the command on the current shelf
'''
#some good default icons:
#menuIconConstraints - !
#render_useBackground - circle
#render_volumeShader - black dot
#menuIconShow - eye
gShelfTopLevel = mm.eval('$temp=$gShelfTopLevel')
if not mc.tabLayout(gShelfTopLevel, exists=True):
OpenMaya.MGlobal.displayWarning('Shelf not visible.')
return
if not name:
name = label
if not image:
image = getIcon(name)
if not image:
image = 'render_useBackground'
shelfTab = mc.shelfTabLayout(gShelfTopLevel, query=True, selectTab=True)
shelfTab = gShelfTopLevel+'|'+shelfTab
#add additional args depending on what version of maya we're in
kwargs = {}
if MAYA_VERSION >= 2009:
kwargs['commandRepeatable'] = True
if MAYA_VERSION >= 2011:
kwargs['overlayLabelColor'] = labelColor
kwargs['overlayLabelBackColor'] = labelBackgroundColor
if backgroundColor:
kwargs['enableBackground'] = bool(backgroundColor)
kwargs['backgroundColor'] = backgroundColor
return mc.shelfButton(parent=shelfTab, label=name, command=command,
imageOverlayLabel=label, image=image, annotation=description,
width=32, height=32, align='center', **kwargs)