pymel.core.windows.promptDialog

static windows.promptDialog(*args, **kwargs)

The promptDialog command creates a modal dialog with a message to the user, a text field in which the user may enter a response, and a variable number of buttons to dismiss the dialog. The dialog is dismissed when the user presses any button or chooses the close item from the window menu. In the case where a button is pressed then the name of the button selected is returned. If the dialog is dismissed via the close item then the string returned is specified by the -ds/dismissStringflag. The default behaviour when no arguments are specified is to create an empty single button dialog. To obtain the text entered by the user simply query the -tx/textflag.

Flags:
Long name (short name) Argument Types Properties
backgroundColor (bgc) float, float, float ../../../_images/create.gif
 

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

button (b) unicode ../../../_images/create.gif
 
Create a button with the given string as it’s text.
cancelButton (cb) unicode ../../../_images/create.gif
 

The cancel button is activated by pressing the escape key. Note that this flag does not create a button, it simply indicates which button created via the -b/buttonflag shall respond to the escape key.

defaultButton (db) unicode ../../../_images/create.gif
 

The default button is activated by pressing the enter key. Note that this flag does not create a button, it simply indicates which button created via the -b/buttonflag shall respond to the enter key.

dismissString (ds) unicode ../../../_images/create.gif
 
The string returned when the user selects the ‘Close’ item from the Window Manager menu. If this flag is not set then the string dismissis returned.
message (m) unicode ../../../_images/create.gif
 
The message text appearing in the dialog.
messageAlign (ma) unicode ../../../_images/create.gif
 
Align the message left, center, or right.
parent (p) unicode ../../../_images/create.gif
 

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.

scrollableField (sf) bool ../../../_images/create.gif
 
By default a single line text field is used in the dialog. Specify true for a multi-line scroll field.
style (st) unicode ../../../_images/create.gif
 
Specify the type of input expected in the input field. Vaid input types are integerfloattext. If this flag is not specified, we assume the input type is text.
text (tx) unicode ../../../_images/create.gif ../../../_images/query.gif
 
The field text.
title (t) unicode ../../../_images/create.gif
 
The dialog title.

Derived from mel command maya.cmds.promptDialog

Example:

import pymel.core as pm

# Create an OK/Cancel prompt dialog.
#
# +-+---------------------+
# |-|    Rename Object    |
# +-----------------------+
# | Enter Name:           |
# | +-------------------+ |
# | |                   | |
# | |                   | |
# | +-------------------+ |
# +-----------------------+
# | +-------+  +--------+ |
# | |  OK   |  | Cancel | |
# | +-------+  +--------+ |
# +-----------------------+
#

result = pm.promptDialog(
            title='Rename Object',
            message='Enter Name:',
            button=['OK', 'Cancel'],
            defaultButton='OK',
            cancelButton='Cancel',
            dismissString='Cancel')

if result == 'OK':
    text = pm.promptDialog(query=True, text=True)

Previous topic

pymel.core.windows.promptBoxGenerator

Next topic

pymel.core.windows.promptForFolder

Core

Core Modules

Other Modules

This Page