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


layoutDialog([backgroundColor=[float, float, float]], [dismiss=string], [parent=string], [title=string], [uiScript=script])

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

layoutDialog is undoable, NOT queryable, and NOT editable.

The layoutDialog command creates a modal dialog containing a formLayout with 100 divisions. The formLayout can be populated with arbitrary UI elements through use of the '-ui/-uiScript' flag.

A layoutDialog is not a window and certain UI elements will not function properly within it. In particular menuBars and panels containing menuBars should not be used with the layoutDialog.

Return value

stringThe string specified by the -dismiss flag, or "dismiss" if the dialog was closed.


backgroundColor, dismiss, parent, title, uiScript
Long name (short name) Argument types Properties
title(t) string create
The dialog title.
dismiss(dis) string create
Dismiss the current layoutDialog. The specified string will be set as the result of the initial layoutDialog command.
parent(p) string create
Specify the parent window for the dialog. The dialog will be centered on this window and raise and lower with it's parent. By default, the dialog is not parented to a particular window and is simply centered on the screen.
backgroundColor(bgc) [float, float, float] create
The background color of the dialog. The arguments correspond to the red, green, and blue color components. Each component ranges in value from 0.0 to 1.0. (Windows only flag)
uiScript(ui) script create
The specified MEL procedure name will be invoked to build the UI of the layoutDialog. This flag is required when creating a layoutDialog. The top-level control of a layoutDialog is a formLayout with 100 divisions. It can be accessed by calling 'setParent -q' at the beginning of the specified MEL procedure.

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

def checkboxPrompt():
	# Get the dialog's formLayout.
	form = cmds.setParent(q=True)

	# layoutDialog's are not resizable, so hard code a size here,
	# to make sure all UI elements are visible.
	cmds.formLayout(form, e=True, width=300)

	t = cmds.text(l='What do you want to do?')

	b1 = cmds.button(l='Abort', c='cmds.layoutDialog( dismiss="Abort" )' )
	b2 = cmds.button(l='Skip', c='cmds.layoutDialog( dismiss="Skip" )' )
	b3 = cmds.button(l='Continue', c='cmds.layoutDialog( dismiss="Continue" )' )

	cb1 = cmds.checkBox(label='Remember my choice')

	spacer = 5
	top = 5
	edge = 5

	cmds.formLayout(form, edit=True,
					attachForm=[(t, 'top', top), (t, 'left', edge), (t, 'right', edge), (b1, 'left', edge), (b3, 'right', edge), (cb1, 'left', edge), (cb1, 'bottom', spacer)],
					attachNone=[(t, 'bottom'), (b1, 'bottom'), (b2, 'bottom'), (b3, 'bottom'), (cb1, 'right')],
					attachControl=[(b1, 'top', spacer, t), (b2, 'top', spacer, t), (b3, 'top', spacer, t), (cb1, 'top', spacer, b1)],
					attachPosition=[(b1, 'right', spacer, 33), (b2, 'left', spacer, 33), (b2, 'right', spacer, 66), (b3, 'left', spacer, 66)])

print cmds.layoutDialog(ui=checkboxPrompt)