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 exists / ex bool Returns true|false depending upon whether the specified uiTemplate exists. Other flags are ignored. Flag 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 # 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 )