2010

Table Of Contents
use it.) You cannot reference or modify windows or controls that you dont
know the name of.
To refer to a user interface element by name
1 Create a window with text and a button that closes it by typing the
following in a MEL tab of the Script Editor:
window -resizeToFitChildren 1 testwindow; columnLayout; text
-label "This is a test window you can close by\ clicking the
button below."; button -label "Close" -command "deleteUI
testwindow"; showWindow;
2 Press the Close button in the window.
The window closes.
Discussion: creating a simple window
In your window, you created elements for your user interface, called controls.
All user interface controls must be created within a layout. Layouts instruct
Maya how to arrange the user interface elements in the window.
There are many different types of layoutsfor example, formLayout and
rowLayoutbut the simplest and easiest to use is the columnLayout. The
columnLayout lays out your controls in a column, one underneath the other.
For more information on layouts, see Layouts of the MEL and Expressions
guide.
Within the layout you created a text control, with the text command. The
label flags argument is the text displayed in the window.
The button is created by the button command. The argument of the command
flag is a MEL command that is executed when the button is pressed. In this
case, pressing the button executes the deleteUI command, which deletes the
window you just created.
Scripts spanning multiple lines
In this script, individual commands span multiple lines. Commands can span
multiple lines as long as the end line character is at the end of the command.
One convention in MEL is to have the command keyword on one line, and
pair the modifier flags and values on separate lines underneath the command,
as in this example.
Creating a window | 685