pymel.core.windows.uiTemplate

uiTemplate(name=None, force=False, exists=None)

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.

Flags:

Long Name / Short Name Argument Types Properties
defineTemplate / dt unicode ../../../_images/create.gif
  Puts the command in a mode where any other flags and arguments are parsed and added to the command template specified in the argument. They will be used as default arguments in any subsequent invocations of the command when templateName is set as the current template.
exists / ex bool ../../../_images/create.gif
  Returns whether the specified object exists or not. Other flags are ignored.
useTemplate / ut unicode ../../../_images/create.gif
  Forces the command to use a command template other than the current one. Flag can have multiple arguments, passed either as a tuple or a list.

Derived from mel command maya.cmds.uiTemplate

Example:

import pymel.core as pm

#    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|columnLayout95') #

pm.frameLayout()
# Result: ui.FrameLayout('window1|columnLayout95|frameLayout26') #
pm.columnLayout()
# Result: ui.ColumnLayout('window1|columnLayout95|frameLayout26|columnLayout96') #
pm.button( label='One' )
# Result: ui.Button('window1|columnLayout95|frameLayout26|columnLayout96|button105') #
pm.button( label='Two' )
# Result: ui.Button('window1|columnLayout95|frameLayout26|columnLayout96|button106') #
pm.button( label='Three' )
# Result: ui.Button('window1|columnLayout95|frameLayout26|columnLayout96|button107') #
pm.setParent( '..' )
# Result: u'window1|columnLayout95|frameLayout26' #
pm.setParent( '..' )
# Result: u'window1|columnLayout95' #

pm.frameLayout()
# Result: ui.FrameLayout('window1|columnLayout95|frameLayout27') #
pm.columnLayout()
# Result: ui.ColumnLayout('window1|columnLayout95|frameLayout27|columnLayout97') #
pm.button( label='Red' )
# Result: ui.Button('window1|columnLayout95|frameLayout27|columnLayout97|button108') #
pm.button( label='Green' )
# Result: ui.Button('window1|columnLayout95|frameLayout27|columnLayout97|button109') #
pm.button( label='Blue' )
# Result: ui.Button('window1|columnLayout95|frameLayout27|columnLayout97|button110') #
pm.setParent( '..' )
# Result: u'window1|columnLayout95|frameLayout27' #
pm.setParent( '..' )
# Result: u'window1|columnLayout95' #

pm.setUITemplate( popTemplate=True )
# Result: u'NONE' #

pm.showWindow( window )