Go to: Synopsis. Return value. Flags. Python examples.
workspaceControlState(
string
, [defaultTopLeftCorner=[int, int]], [defaultWidthHeight=[int, int]], [exists=boolean], [height=int], [leftEdge=int], [maximized=boolean], [remove=boolean], [topEdge=int], [topLeftCorner=[int, int]], [width=int], [widthHeight=[int, int]])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
workspaceControlState is undoable, queryable, and editable.
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.
None
In query mode, return type is based on queried flag.
defaultTopLeftCorner, defaultWidthHeight, exists, height, leftEdge, maximized, remove, topEdge, topLeftCorner, width, widthHeight
Long name (short name) |
Argument types |
Properties |
|
defaultTopLeftCorner(dc)
|
[int, int]
|
 
|
|
Top and left edge position that the window will have when "Remember size and position" is 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]
|
 
|
|
Width and height that the window will have when "Remember size and position" is 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)
|
boolean
|
|
|
Returns true|false depending upon whether the specified object
exists. Other flags are ignored.
|
|
height(h)
|
int
|
 
|
|
leftEdge(le)
|
int
|
 
|
|
Left edge position of the window.
|
|
maximized(max)
|
boolean
|
 
|
|
remove(r)
|
boolean
|
|
|
Remove a window preference.
|
|
topEdge(te)
|
int
|
 
|
|
Top edge position of the window.
|
|
topLeftCorner(tlc)
|
[int, int]
|
 
|
|
Top and left edge position of the window.
|
|
width(w)
|
int
|
 
|
|
widthHeight(wh)
|
[int, int]
|
 
|
|
Width and height of the window.
|
|
Flag can appear in Create mode of command
|
Flag can appear in Edit mode of command
|
Flag can appear in Query mode of command
|
Flag can have multiple arguments, passed either as a tuple or a list.
|
import maya.cmds as cmds
# Check if the window exists.
#
if cmds.window('ExampleWindow', exists=True):
cmds.deleteUI('ExampleWindow', window=True)
# Create a window.
#
cmds.window( 'ExampleWindow' )
cmds.columnLayout()
cmds.text( label='Size and position the window before closing it.' )
cmds.button( label='Close', command='cmds.deleteUI("ExampleWindow", window=True)' )
cmds.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.
#
cmds.workspaceControlState( 'ExampleWindow', exists=True )
# Query the window preference size and position.
#
cmds.workspaceControlState( 'ExampleWindow', query=True, topLeftCorner=True )
cmds.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 cmds.window('ExampleWindow', exists=True):
cmds.deleteUI('ExampleWindow', window=True)
cmds.window( 'ExampleWindow' )
cmds.columnLayout()
cmds.text( label='Size and position the window before closing it.' )
cmds.button( label='Close', command='cmds.deleteUI("ExampleWindow", window=True)' )
cmds.showWindow( 'ExampleWindow' )
# Delete the window preference and the window will have a
# default size and position.
#
cmds.workspaceControlState( 'ExampleWindow', remove=True )
# Create the window one last time.
#
if cmds.window('ExampleWindow', exists=True):
cmds.deleteUI('ExampleWindow', window=True)
cmds.window( 'ExampleWindow' )
cmds.columnLayout()
cmds.text( label='Size and position the window before closing it.' )
cmds.button( label='Close', command='cmds.deleteUI("ExampleWindow", window=True)' )
cmds.showWindow( 'ExampleWindow' )