Your Ad Here

Go to: Synopsis. Flags. Return value. Python examples.

Synopsis

windowPref( windowName , [edit=boolean], [exists=boolean], [height=int], [leftEdge=int], [loadAll=boolean], [parentMain=boolean], [query=boolean], [remove=boolean], [removeAll=boolean], [saveAll=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.

windowPref is undoable, queryable, and editable.

Create or modify preferred window attributes. The size and position of a window is retained during and between application sessions. A default window preference is created when a window is closed. Window preferences must be named and, consequently, only affect the window with a matching name. Note that window preferences are not applied to the main Maya window nor the Command window.

Flags

edit, exists, height, leftEdge, loadAll, parentMain, query, remove, removeAll, saveAll, topEdge, topLeftCorner, width, widthHeight
Long name (short name) [argument types] Properties
query(q) boolean query
Puts the command in query mode so that it will return the value of the specified flag.

In query mode, this flag needs a value.

edit(e) boolean edit
Puts the command in edit mode so that it will change the values of the specified flags.
exists(ex) boolean create
Returns true|false depending upon whether the specified object exists. Other flags are ignored.
topEdge(te) int createqueryedit
Top edge position of the window.

In query mode, this flag needs a value.

leftEdge(le) int createqueryedit
Left edge position of the window.

In query mode, this flag needs a value.

topLeftCorner(tlc) [int, int] createqueryedit
Top and left edge position of the window.

In query mode, this flag needs a value.

width(w) int createqueryedit
Width of the window.

In query mode, this flag needs a value.

height(h) int createqueryedit
Height of the window.

In query mode, this flag needs a value.

widthHeight(wh) [int, int] createqueryedit
Width and height of the window.

In query mode, this flag needs a value.

parentMain(pm) boolean createquery
Set whether window is parented to main application window. Windows only. -enableAll boolean Enable/disable all window preferences. Preferences are enabled by default. Set this flag to false and window's will ignore all preference values.

In query mode, this flag needs a value.

remove(r) boolean create
Remove a window preference.
removeAll(ra) boolean create
Remove all window preferences.
saveAll(sa) boolean create
Writes out file with window attributes.
loadAll(la) boolean create
Reads in file with window attributes from disk.

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.

Return value


Nothing.

Python examples

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.windowPref( 'ExampleWindow', exists=True )

#    Query the window preference size and position.
#
cmds.windowPref( 'ExampleWindow', query=True, topLeftCorner=True )
cmds.windowPref( '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.windowPref( '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' )

  

Return to Autodesk Index


Your Ad Here