Python maya.cmds.shelfButton() Examples
The following are 7
code examples of maya.cmds.shelfButton().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
maya.cmds
, or try the search function
.
Example #1
Source File: install.py From maya-skinning-tools with GNU General Public License v3.0 | 6 votes |
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)
Example #2
Source File: install.py From maya-spline-ik with GNU General Public License v3.0 | 5 votes |
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)
Example #3
Source File: install.py From maya-retarget-blendshape with GNU General Public License v3.0 | 5 votes |
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)
Example #4
Source File: shelf.py From dpa-pipe with MIT License | 5 votes |
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) # -------------------------------------------------------------------------
Example #5
Source File: ml_controlLibrary.py From ml_tools with MIT License | 5 votes |
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))
Example #6
Source File: install.py From maya-keyframe-reduction with MIT License | 5 votes |
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)
Example #7
Source File: ml_utilities.py From ml_tools with MIT License | 4 votes |
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)