This command creates a new command template object. Template objects can hold default flag arguments for multiple UI commands. The command arguments are specified with the individual commands using the -defineTemplate flag and the desired flags and arguments. See also setUITemplate.
Long name (short name) | Argument Types | Properties | |
---|---|---|---|
defineTemplate (dt) | unicode | ||
exists (ex) | bool | ||
Returns true|false depending upon whether the specified uiTemplate exists. Other flags are ignored.Flag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list. |
|||
useTemplate (ut) | unicode | ||
Derived from mel command maya.cmds.uiTemplate
Example:
import pymel.core as pm
import maya.cmds as cmds
# Create a new template.
#
if pm.uiTemplate( 'ExampleTemplate', exists=True ):
pm.deleteUI( 'ExampleTemplate', uiTemplate=True )
pm.uiTemplate( 'ExampleTemplate' )
# Result: UITemplate(u'ExampleTemplate') #
pm.button( defineTemplate='ExampleTemplate', width=100, height=40, align='left' )
pm.frameLayout( defineTemplate='ExampleTemplate', borderVisible=True, labelVisible=False )
# Create a window and apply the template.
#
window = pm.window()
pm.setUITemplate( 'ExampleTemplate', pushTemplate=True )
# Result: u'ExampleTemplate' #
pm.columnLayout( rowSpacing=5 )
# Result: ui.ColumnLayout('window1|columnLayout94') #
pm.frameLayout()
# Result: ui.FrameLayout('window1|columnLayout94|frameLayout24') #
pm.columnLayout()
# Result: ui.ColumnLayout('window1|columnLayout94|frameLayout24|columnLayout95') #
pm.button( label='One' )
# Result: ui.Button('window1|columnLayout94|frameLayout24|columnLayout95|button103') #
pm.button( label='Two' )
# Result: ui.Button('window1|columnLayout94|frameLayout24|columnLayout95|button104') #
pm.button( label='Three' )
# Result: ui.Button('window1|columnLayout94|frameLayout24|columnLayout95|button105') #
pm.setParent( '..' )
# Result: u'window1|columnLayout94|frameLayout24' #
pm.setParent( '..' )
# Result: u'window1|columnLayout94' #
pm.frameLayout()
# Result: ui.FrameLayout('window1|columnLayout94|frameLayout25') #
pm.columnLayout()
# Result: ui.ColumnLayout('window1|columnLayout94|frameLayout25|columnLayout96') #
pm.button( label='Red' )
# Result: ui.Button('window1|columnLayout94|frameLayout25|columnLayout96|button106') #
pm.button( label='Green' )
# Result: ui.Button('window1|columnLayout94|frameLayout25|columnLayout96|button107') #
pm.button( label='Blue' )
# Result: ui.Button('window1|columnLayout94|frameLayout25|columnLayout96|button108') #
pm.setParent( '..' )
# Result: u'window1|columnLayout94|frameLayout25' #
pm.setParent( '..' )
# Result: u'window1|columnLayout94' #
pm.setUITemplate( popTemplate=True )
# Result: u'NONE' #
pm.showWindow( window )