pymel.core.windows.workspaceControlState

workspaceControlState(*args, **kwargs)

Create or modify preferred window attributes for workspace controls. The size and position of a workspace control is retained during application sessions (although position only applies to workspace controls that are alone in a floating workspace docking panel). A default workspace control state is created when a workspace control is closed. Workspace control states must be named and, consequently, only affect the workspace control with a matching name. In query mode, return type is based on queried flag.

Flags:

Long Name / Short Name Argument Types Properties
defaultTopLeftCorner / dc int, int ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Top and left edge position that the window will have when Remember size and positionis off and when the panel is first opened. The values will be DPI scaled on edit and the value in query is returned unscaled. This value will only be used if the default width and height are also valid.
defaultWidthHeight / dwh int, int ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Width and height that the window will have when Remember size and positionis off and when the panel is first opened. The values will be DPI scaled on edit and the value in query is returned unscaled. The position used in that case is defaultTopLeftCorner.
exists / ex bool ../../../_images/create.gif
  Returns true|false depending upon whether the specified object exists. Other flags are ignored.
height / h int ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Height of the window.
leftEdge / le int ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Left edge position of the window.
maximized / max bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Maximize the window.
remove / r bool ../../../_images/create.gif
  Remove a window preference.
topEdge / te int ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Top edge position of the window.
topLeftCorner / tlc int, int ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Top and left edge position of the window.
width / w int ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Width of the window.
widthHeight / wh int, int ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
  Width and height of the window. Flag can have multiple arguments, passed either as a tuple or a list.

Derived from mel command maya.cmds.workspaceControlState

Example:

::

import pymel.core as pm

# Check if the window exists. # if pm.window(‘ExampleWindow’, exists=True):

pm.deleteUI(‘ExampleWindow’, window=True)

# Create a window. # pm.window( ‘ExampleWindow’ ) # Result: ui.Window(‘ExampleWindow’) # pm.columnLayout() # Result: ui.ColumnLayout(‘ExampleWindow|columnLayout8’) # pm.text( label=’Size and position the window before closing it.’ ) # Result: ui.Text(‘ExampleWindow|columnLayout8|text94’) # pm.button( label=’Close’, command=’pm.deleteUI(“ExampleWindow”, window=True)’ ) # Result: ui.Button(‘ExampleWindow|columnLayout8|button26’) # pm.showWindow( ‘ExampleWindow’ )

# When the window is closed a window preference object is # created for the window. It has the same name as the window # object. # pm.workspaceControlState( ‘ExampleWindow’, exists=True ) # Result: False #

# Query the window preference size and position. # pm.workspaceControlState( ‘ExampleWindow’, query=True, topLeftCorner=True ) pm.workspaceControlState( ‘ExampleWindow’, query=True, widthHeight=True )

# Create a window with the same name. When it is shown # it will be sized and positioned according to the # window preference. # if pm.window(‘ExampleWindow’, exists=True):

pm.deleteUI(‘ExampleWindow’, window=True)

pm.window( ‘ExampleWindow’ ) pm.columnLayout() pm.text( label=’Size and position the window before closing it.’ ) pm.button( label=’Close’, command=’pm.deleteUI(“ExampleWindow”, window=True)’ ) pm.showWindow( ‘ExampleWindow’ )

# Delete the window preference and the window will have a # default size and position. # pm.workspaceControlState( ‘ExampleWindow’, remove=True )

# Create the window one last time. # if pm.window(‘ExampleWindow’, exists=True):

pm.deleteUI(‘ExampleWindow’, window=True)

pm.window( ‘ExampleWindow’ ) pm.columnLayout() pm.text( label=’Size and position the window before closing it.’ ) pm.button( label=’Close’, command=’pm.deleteUI(“ExampleWindow”, window=True)’ ) pm.showWindow( ‘ExampleWindow’ )