pymel.core.windows.window

window(*args, **kwargs)

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.

Flags:
Long name (short name) Argument Types Properties
backgroundColor (bgc) float, float, float ../../../_images/create.gif ../../../_images/edit.gif
 
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.
defineTemplate (dt) unicode ../../../_images/create.gif
 

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.

docTag (dtg) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Attach a tag to the window.
exists (ex) bool ../../../_images/create.gif
 
Returns true|false depending upon whether the specified object exists. Other flags are ignored.
frontWindow (fw) bool ../../../_images/query.gif
 

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 commandFlag can have multiple arguments, passed either as a tuple or a list.

height (h) int ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Height of the window excluding any window frame in pixels.
iconName (iconName) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
The window’s icon title. By default it is the same as the window’s title.
iconify (i) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Icon state of the window.
interactivePlacement (ip) bool ../../../_images/create.gif
 
Deprecated flag. Recognized but not implemented. This flag will be removed in a future version of Maya.
leftEdge (le) int ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Position of the left edge of the window.
mainMenuBar (mm) bool  
   
mainWindow (mw) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
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.
maximizeButton (mxb) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Turns the window’s maximize button on or off
menuArray (ma) bool ../../../_images/query.gif
 
Return a string array containing the names of the menus in the window’s menu bar.
menuBar (mb) bool ../../../_images/create.gif ../../../_images/query.gif
 
Adds an empty menu bar to the window.
menuBarVisible (mbv) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Visibility of the menu bar (if there is one).
menuIndex (mi) unicode, int ../../../_images/edit.gif
 
Sets the index of a specified menu.
minimizeButton (mnb) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Turns the window’s minimize button on or off.
minimizeCommand (mnc) script ../../../_images/create.gif ../../../_images/edit.gif
 
Script executed after the window is minimized (iconified).
numberOfMenus (nm) bool ../../../_images/query.gif
 
Return the number of menus attached to the window’s menu bar.
resizeToFitChildren (rtf) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
The window will always grow/shrink to just fit the controls it contains.
restoreCommand (rc) script ../../../_images/create.gif ../../../_images/edit.gif
 
Script executed after the window is restored from it’s minimized (iconified) state.
retain (ret) bool ../../../_images/create.gif
 
Retains the window after it has been closed. The default is to delete the window when it is closed.
sizeable (s) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Whether or not the window may be interactively resized.
title (t) unicode ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
The window’s title.
titleBar (tb) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Turns the window’s title bar on or off.
titleBarMenu (tbm) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Controls whether the title bar menu exists in the window title bar. Only valid if -tb/titleBaris true. This Windows only flag is true by default.
toolbox (tlb) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Makes this a toolbox style window. A Windows only flag that makes the title bar smaller and uses a slightly different display style.
topEdge (te) int ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Position of the top edge of the window.
topLeftCorner (tlc) int, int ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Position of the window’s top left corner.
useTemplate (ut) unicode ../../../_images/create.gif
 
Force the command to use a command template other than the current one.
visible (vis) bool ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
The window’s visibility.
width (w) int ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Width of the window excluding any window frame in pixels.
widthHeight (wh) int, int ../../../_images/create.gif ../../../_images/query.gif ../../../_images/edit.gif
 
Window’s width and height excluding any window frame in pixels.

Derived from mel command maya.cmds.window

Example:

import pymel.core as pm

import maya.cmds as cmds

# Make a new window
#
window = pm.window( title="Long Name", iconName='Short Name', widthHeight=(200, 55) )
pm.columnLayout( adjustableColumn=True )
# Result: ui.ColumnLayout('window1|columnLayout97') #
pm.button( label='Do Nothing' )
# Result: ui.Button('window1|columnLayout97|button109') #
pm.button( label='Close', command=('pm.deleteUI(\"' + window + '\", window=True)') )
# Result: ui.Button('window1|columnLayout97|button110') #
pm.setParent( '..' )
# Result: u'' #
pm.showWindow( window )

# Resize the main window
#

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

Previous topic

pymel.core.windows.webBrowserPrefs

Next topic

pymel.core.windows.windowPref

Core

Core Modules

Other Modules

This Page