This command saves the specified shelf (first argument) to the specified file (second argument). Note that this command doesn’t work well with controls that have mixed mel and python command callbacks. Also, because it saves the state to a mel file, it does not work with callbacks that are python callable objects.
Derived from mel command maya.cmds.saveShelf
Example:
import pymel.core as pm
import maya.cmds as cmds
# Create a window with a shelf in it.
#
window = pm.window()
tabs = pm.tabLayout()
shelf = pm.shelfLayout()
pm.shelfButton( '\"Hello\\n\"")', image1='commandButton.png', command='("print' )
# Result: ui.ShelfButton('window1|tabLayout4|shelfLayout1|Hello_n___') #
pm.tabLayout( tabs, edit=True, tabLabel=(str(shelf),'Example Shelf') )
# Result: ui.TabLayout('window1|tabLayout4') #
pm.showWindow( window )
# At this point the example would be made more interesting if you
# put some additional items on this shelf.
# Now save the shelf in the temp directory.
#
tempDir = pm.internalVar( userTmpDir=True )
pm.saveShelf( shelf, (tempDir + 'ExampleShelf') );