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


window( [string] , [backgroundColor=[float, float, float]], [defineTemplate=string], [docTag=string], [exists=boolean], [frontWindow=boolean], [height=int], [iconName=string], [iconify=boolean], [interactivePlacement=boolean], [leftEdge=int], [mainWindow=boolean], [maximizeButton=boolean], [menuArray=boolean], [menuBar=boolean], [menuBarVisible=boolean], [menuIndex=[string, uint]], [minimizeButton=boolean], [minimizeCommand=script], [numberOfMenus=boolean], [resizeToFitChildren=boolean], [restoreCommand=script], [retain=boolean], [sizeable=boolean], [title=string], [titleBar=boolean], [titleBarMenu=boolean], [toolbox=boolean], [topEdge=int], [topLeftCorner=[int, int]], [useTemplate=string], [visible=boolean], [width=int], [widthHeight=[int, int]])

Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.

window is undoable, queryable, and editable.

This command creates a new window but leaves it invisible. It is most efficient to add the window's elements and then make it visible with the showWindow command. The window can have an optional menu bar. Also, the title bar and minimize/maximize buttons can be turned on or off. If the title bar is off, then you cannot have minimize or maximize buttons.

Note: The window will require a control layout of some kind to arrange the controls (buttons, sliders, fields, etc.). Examples of control layouts are columnLayout, formLayout, rowLayout, etc.

Note: This command will clear the uiTemplate stack. Templates for a window need to be set after the window cmd.

Return value

stringName to the window.

In query mode, return type is based on queried flag.


backgroundColor, defineTemplate, docTag, exists, frontWindow, height, iconName, iconify, interactivePlacement, leftEdge, mainWindow, maximizeButton, menuArray, menuBar, menuBarVisible, menuIndex, minimizeButton, minimizeCommand, numberOfMenus, resizeToFitChildren, restoreCommand, retain, sizeable, title, titleBar, titleBarMenu, toolbox, topEdge, topLeftCorner, useTemplate, visible, width, widthHeight
Long name (short name) Argument types Properties
exists(ex) boolean create
Returns true|false depending upon whether the specified object exists. Other flags are ignored.
defineTemplate(dt) string create
Puts a command in a mode where any other flags and args 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.
useTemplate(ut) string create
Force the command to use a command template other than the current one.
title(t) string createqueryedit
The window's title.
iconName(iconName) string createqueryedit
The window's icon title. By default it is the same as the window's title.
sizeable(s) boolean createqueryedit
Whether or not the window may be interactively resized.
titleBar(tb) boolean createqueryedit
Turns the window's title bar on or off.
minimizeButton(mnb) boolean createqueryedit
Turns the window's minimize button on or off.
maximizeButton(mxb) boolean createqueryedit
Turns the window's maximize button on or off
menuBar(mb) boolean createquery
Adds an empty menu bar to the window. the Qt name of the object will be m_menubar_nameOfTheWindow
toolbox(tlb) boolean createqueryedit
Makes this a toolbox style window. A Windows only flag that makes the title bar smaller and uses a slightly different display style.
titleBarMenu(tbm) boolean createqueryedit
Controls whether the title bar menu exists in the window title bar. Only valid if -tb/titleBar is true. This Windows only flag is true by default.
menuBarVisible(mbv) boolean createqueryedit
Visibility of the menu bar (if there is one).
topEdge(te) int createqueryedit
Position of the top edge of the window.
leftEdge(le) int createqueryedit
Position of the left edge of the window.
topLeftCorner(tlc) [int, int] createqueryedit
Position of the window's top left corner.
width(w) int createqueryedit
Width of the window excluding any window frame in pixels.
height(h) int createqueryedit
Height of the window excluding any window frame in pixels.
widthHeight(wh) [int, int] createqueryedit
Window's width and height excluding any window frame in pixels.
retain(ret) boolean create
Retains the window after it has been closed. The default is to delete the window when it is closed.
visible(vis) boolean createqueryedit
The window's visibility.
iconify(i) boolean createqueryedit
Icon state of the window.
mainWindow(mw) boolean createqueryedit
Main window for the application. The main window has an 'Exit' item in the Window Manager menu. By default, the first created window becomes the main window.
backgroundColor(bgc) [float, float, float] createedit
The background color of the window. The arguments correspond to the red, green, and blue color components. Each component ranges in value from 0.0 to 1.0.
resizeToFitChildren(rtf) boolean createqueryedit
The window will always grow/shrink to just fit the controls it contains.
interactivePlacement(ip) boolean create
Deprecated flag. Recognized but not implemented. This flag will be removed in a future version of Maya.
minimizeCommand(mnc) script createedit
Script executed after the window is minimized (iconified).
restoreCommand(rc) script createedit
Script executed after the window is restored from it's minimized (iconified) state.
numberOfMenus(nm) boolean query
Return the number of menus attached to the window's menu bar.
menuArray(ma) boolean query
Return a string array containing the names of the menus in the window's menu bar.
menuIndex(mi) [string, uint] edit
Sets the index of a specified menu.
docTag(dtg) string createqueryedit
Attach a tag to the window.
frontWindow(fw) boolean query
Return the name of the front window. Note: you must supply the name of any window (the window does not need to exist). Returns "unknown" if the front window cannot be determined.

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.

Python examples

import maya.cmds as cmds

# Make a new window
window = cmds.window( title="Long Name", iconName='Short Name', widthHeight=(200, 55) )
cmds.columnLayout( adjustableColumn=True )
cmds.button( label='Do Nothing' )
cmds.button( label='Close', command=('cmds.deleteUI(\"' + window + '\", window=True)') )
cmds.setParent( '..' )
cmds.showWindow( window )

# Resize the main window

# This is a workaround to get MEL global variable value in Python
gMainWindow = maya.mel.eval('$tmpVar=$gMainWindow')
cmds.window( gMainWindow, edit=True, widthHeight=(900, 777) )