Go to: Synopsis. Return value. Flags. Python examples.
loadUI([listTypes=boolean], [uiFile=string], [uiString=string], [verbose=boolean], [workingDirectory=string])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
loadUI is undoable, NOT queryable, and NOT editable.
loadUI command allows loading of a user interface created in Trolltech Qt Designer.
Some Qt classes have equivalents in Maya. If a widget's class is recognized, the Maya-equivelent will be created instead.
Any dynamic properties on a widget which start with a '-' character will be treated as a MEL flag/value pair. Similarly, any which start with a '+' will be treated as a Python flag/value pair. Such pairs will be applied to the widget upon creation.
string | Full path name to the root control. |
listTypes, uiFile, uiString, verbose, workingDirectory
Long name (short name) |
Argument types |
Properties |
|
listTypes(lt)
|
boolean
|
|
|
Returns the list of recognized UI types and their associated Maya command.
|
|
uiFile(f)
|
string
|
|
|
Full path to a user interface file to load.
|
|
uiString(s)
|
string
|
|
|
Load UI from a formated string.
|
|
verbose(v)
|
boolean
|
|
|
Extra information about created controls will be printed.
|
|
workingDirectory(wd)
|
string
|
|
|
Sets the working directory, the loader looks for resources
such as icons and resouce files in paths relative to this directory.
|
|
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.
|
import maya.cmds as cmds
# Note: mydialog.ui must already exist
dialog1 = cmds.loadUI(f='/users/username/mydialog.ui')
cmds.showWindow(dialog1)
# Load from a string
dialogString = \
r"""<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="mylabel">
<property name="text">
<string>Test Dialog</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mybutton">
<property name="text">
<string>Press Me</string>
</property>
<property name="+command">
<string>"import time;cmds.text('mylabel',e=True,label='CPU Time: '+repr(time.clock()))"</string>
</property>
</widget>
</item>
</layout>
</widget>
</ui>
"""
dialog2 = cmds.loadUI(uiString=dialogString)
cmds.showWindow(dialog2)