[Maya Python] Create and Edit a Shelf Button

Submitted by Benoit on Sat, 04/24/2010 - 17:35

Here is a simple example creating and editing a shelf button.

Example:

#=========================================================================
# This script creates and edits a shelf button in Maya
#=========================================================================
 
# Import PyMel 0.9.2
import pymel as pm 
 
# Create ShelfLyout PyNode for TEST Maya shelf
myShelf = pm.ShelfLayout('TEST')
 
# Create a ShelfButton
myShelfButton = pm.ShelfButton(parent = myShelf,
                               enable = 1,
                               annotation = "Create a sphere",
                               label = "Create a sphere",
                               image1 = "sphere.xpm",
                               style = "iconOnly",
                               command = "pm.polySphere()")
 
# Edit a ShelfButton
myShelfButton.setCommand("pm.sphere()")

Best regards,
Benoît