python中button对象的方法_Python cmds.shelfButton方法代码示例

# 需要导入模块: 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)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值