本文整理汇总了Python中maya.cmds.tabLayout方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.tabLayout方法的具体用法?Python cmds.tabLayout怎么用?Python cmds.tabLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类maya.cmds
的用法示例。
在下文中一共展示了cmds.tabLayout方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: shelf
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import tabLayout [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: dpColorizeUI
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import tabLayout [as 别名]
def dpColorizeUI(self, *args):
""" Show a little window to choose the color of the button and the override the guide.
"""
#Get Maya colors
#Manually add the "none" color
colorList = [[0.627, 0.627, 0.627]]
#WARNING --> color index in maya start to 1
colorList += [cmds.colorIndex(iColor, q=True) for iColor in range(1,32)]
# creating colorOverride Window:
if cmds.window('dpColorOverrideWindow', query=True, exists=True):
cmds.deleteUI('dpColorOverrideWindow', window=True)
colorOverride_winWidth = 170
colorOverride_winHeight = 115
dpColorOverrideWin = cmds.window('dpColorOverrideWindow', title='Color Override '+DPCO_VERSION, iconName='dpColorOverride', widthHeight=(colorOverride_winWidth, colorOverride_winHeight), menuBar=False, sizeable=True, minimizeButton=False, maximizeButton=False, menuBarVisible=False, titleBar=True)
# creating layout:
colorTabLayout = cmds.tabLayout('colorTabLayout', innerMarginWidth=5, innerMarginHeight=5, parent=dpColorOverrideWin)
# Index layout:
colorIndexLayout = cmds.gridLayout('colorIndexLayout', numberOfColumns=8, cellWidthHeight=(20,20), parent=colorTabLayout)
# creating buttons
for colorIndex, colorValues in enumerate(colorList):
cmds.button('indexColor_'+str(colorIndex)+'_BT', label=str(colorIndex), backgroundColor=(colorValues[0], colorValues[1], colorValues[2]), command=partial(self.dpSetColorIndexToSelect, colorIndex), parent=colorIndexLayout)
# RGB layout:
colorRGBLayout = cmds.columnLayout('colorRGBLayout', adjustableColumn=True, columnAlign='left', rowSpacing=10, parent=colorTabLayout)
cmds.separator(height=10, style='none', parent=colorRGBLayout)
self.colorRGBSlider = cmds.colorSliderGrp('colorRGBSlider', label='Color', columnAlign3=('right', 'left', 'left'), columnWidth3=(30, 60, 50), columnOffset3=(10, 10, 10), rgbValue=(0, 0, 0), changeCommand=self.dpSetColorRGBToSelect, parent=colorRGBLayout)
# renaming tabLayouts:
cmds.tabLayout(colorTabLayout, edit=True, tabLabel=((colorIndexLayout, "Index"), (colorRGBLayout, "RGB")))
# call colorIndex Window:
cmds.showWindow(dpColorOverrideWin)
示例3: shelf
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import tabLayout [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)
示例4: add_callbacks
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import tabLayout [as 别名]
def add_callbacks(self):
""" add callbacks """
if self.callbacks.length() <= 1:
self.logger.debug('Add selection shanged callback')
m_node = node_utils.get_mobject_from_name(self._node)
self.callbacks.append(om.MEventMessage.addEventCallback('SelectionChanged', self.selection_changed))
# def add_ae_change_command(self):
# ae_tabs = maya.mel.eval('$temp = $gAETabLayoutName;')
# cmds.tabLayout(ae_tabs, e=True, changeCommand=self.ae_tab_switched)
示例5: set_active
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import tabLayout [as 别名]
def set_active(self):
prop = cmds.toolPropertyWindow(q=True, loc=True)
cmds.tabLayout(prop, e=True, selectTab=self.name)
# ---------------------------------------------
# convenience constants
示例6: buildMainLayout
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import tabLayout [as 别名]
def buildMainLayout(self):
'''Build the main part of the ui
'''
#tabs = mc.tabLayout()
#tab1 = mc.columnLayout(adj=True)
#self.swatch_selected = self.colorControlLayout()
#mc.button(label='Color Selected', command=self.colorSelected)
#mc.setParent('..')
#tab2 = mc.columnLayout(adj=True)
self.swatch_range1 = self.colorControlLayout(label='First Selected')
self.swatch_range2 = self.colorControlLayout(label='Last Selected')
mc.separator(horizontal=True, height=10)
mc.button(label='Color Selected Nodes', command=self.colorSelectedRange)
#mc.setParent('..')
#tab3 = mc.columnLayout(adj=True)
#self.positionWidgets = {}
#for xyz in 'XYZ':
#for m in ['Min','Max']:
#self.positionWidgets[m+xyz] = self.colorControlLayout(label='{} {}'.format(m,xyz))
mc.setParent('..')
#mc.tabLayout( tabs, edit=True, tabLabel=((tab1, 'Color Control'), (tab2, 'Color Range')) )
示例7: buildMainLayout
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import tabLayout [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)
示例8: update_instance_list
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import tabLayout [as 别名]
def update_instance_list(self, *args):
""" update the instance listi.
1. try to get current node based on ae tab name. this failse if the
nodename is not unique. if this happends...
2. try to get the node based on last item in selection. this fails
if not the item is not a spore shape or spore transform.
this method fails when:
- two spore locator are parented under the same transform.
- the user reaches the node interface without selecting the node """
found = False
# get current ae tab name
ae_tabs = mel.eval('$temp = $gAETabLayoutName;')
tab_index = int(cmds.tabLayout(ae_tabs, q=1, st=1).replace('formTab', ''))
current_tab = cmds.tabLayout(ae_tabs, q=1, tl=1)[tab_index]
# try to get node based on selection
selection = cmds.ls(sl=True, l=True)[-1]
shapes = cmds.listRelatives(selection, s=True, f=True)
# check if node name is unique or selection is node
nodes = cmds.ls(current_tab, l=True)
if len(nodes) == 1 or cmds.objectType(selection) == 'sporeNode':
if cmds.objectType(selection) == 'sporeNode':
self._node = selection
else:
self._node = nodes[0]
found = True
if len(nodes) > 1:
if shapes:
# note: this fails in case there are two spore nodes parented under
# the same transform
for i, shape in enumerate(shapes):
if cmds.objectType(shape) == 'sporeNode':
self._node = shape
found = True
else:
# TODO - we could also try to catch node based on instancer
# ae tab name. this would also fail if the instancer name is
# not unique
pass
cmds.textScrollList('instanceList', e=1, removeAll=True)
if found:
instanced_geo = node_utils.get_instanced_geo(self._node)
instanced_geo = ['[{}]: {}'.format(i, name) for i, name in enumerate(instanced_geo)]
cmds.textScrollList('instanceList', e=1, append=instanced_geo)
else:
msg = 'Could not update objects list. Node name "{}" not unique'.format(current_tab)
self.logger.warn(msg)
cmds.textScrollList('instanceList', e=1, append=msg.split('. '))
示例9: ui
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import tabLayout [as 别名]
def ui():
'''
User interface for world bake
'''
with utl.MlUi('ml_worldBake', 'World Bake', width=400, height=175, info='''Select objects, bake to locators in world, camera, or custom space.
When you're ready to bake back, select locators
and bake "from locators" to re-apply your animation.''') as win:
mc.checkBoxGrp('ml_worldBake_bakeOnOnes_checkBox',label='Bake on Ones',
annotation='Bake every frame. If deselected, the tool will preserve keytimes.')
tabs = mc.tabLayout()
tab1 = mc.columnLayout(adj=True)
mc.radioButtonGrp('ml_worldBake_space_radioButton', label='Bake To Space', numberOfRadioButtons=3,
labelArray3=('World','Camera','Last Selected'), select=1,
annotation='The locators will be parented to world, the current camera, or the last selection.')
mc.checkBoxGrp('ml_worldBake_constrain_checkBox',label='Maintain Constraints',
annotation='Constrain source nodes to the created locators, after baking.')
win.ButtonWithPopup(label='Bake Selection To Locators', command=toLocators, annotation='Bake selected object to locators specified space.',
readUI_toArgs={'bakeOnOnes':'ml_worldBake_bakeOnOnes_checkBox',
'spaceInt':'ml_worldBake_space_radioButton',
'constrainSource':'ml_worldBake_constrain_checkBox'},
name=win.name)#this last arg is temp..
mc.setParent('..')
tab2 = mc.columnLayout(adj=True)
win.ButtonWithPopup(label='Bake Selected Locators Back To Objects', command=fromLocators, annotation='Bake from selected locators back to their source objects.',
readUI_toArgs={'bakeOnOnes':'ml_worldBake_bakeOnOnes_checkBox'}, name=win.name)#this last arg is temp..
mc.setParent('..')
tab3 = mc.columnLayout(adj=True)
win.ButtonWithPopup(label='Re-Parent Animated', command=reparent, annotation='Parent all selected nodes to the last selection.',
readUI_toArgs={'bakeOnOnes':'ml_worldBake_bakeOnOnes_checkBox'}, name=win.name)
win.ButtonWithPopup(label='Un-Parent Animated', command=unparent, annotation='Parent all selected to world.',
readUI_toArgs={'bakeOnOnes':'ml_worldBake_bakeOnOnes_checkBox'}, name=win.name)
mc.separator()
mc.checkBoxGrp('ml_worldBake_maintainOffset_checkBox',label='Maintain Offset',
annotation='Maintain the offset between nodes, rather than snapping.')
win.ButtonWithPopup(label='Bake Selected', command=utl.matchBake, annotation='Bake from the first selected object directly to the second.',
readUI_toArgs={'bakeOnOnes':'ml_worldBake_bakeOnOnes_checkBox',
'maintainOffset':'ml_worldBake_maintainOffset_checkBox'}, name=win.name)
mc.tabLayout( tabs, edit=True, tabLabel=((tab1, 'Bake To Locators'), (tab2, 'Bake From Locators'), (tab3, 'Bake Selection')) )
# win.ButtonWithPopup(label='Bake Selected With Offset', command=matchBake, annotation='Bake from the first selected object directly to the second, maintaining offset.',
# readUI_toArgs={'bakeOnOnes':'ml_worldBake_bakeOnOnes_checkBox'}, name=win.name)#this last arg is temp..
示例10: createShelfButton
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import tabLayout [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)