Maya Python GUI: Difference between revisions
From wikinotes
No edit summary |
(No difference)
|
Latest revision as of 20:41, 2 May 2015
Autodesk has gone through considerable effort to keep flags (both long form and short form) identical in both mel and python for a more seamless experience. Here is a general introduction/quirks for the uninitiated. If you're familiar with mel, you can get used working with the python GUI in a day or less.
## The name of the GUI element is always first ex: window( (name+'Window'), w=100, h=50 )
## Queries expect booleans, for the query flag, ex: window( (name+'Window'), q=1 , w=1 )
## and the desired information. Can use 'True'
## or '1'
## Flags requiring multiple values accept a list ex: button( rgb=[ 0.5, 0.5, 0.5 ] )
## Indentation needs to remain constant, even when ex: paneLayout( configuration='single' )
## you may wish otherwise such as nested GUI elements button( l='test' )
## This really sucks for readability setParent( u=1 )
## Example: Creating a window
from maya.cmds import *
if ( window( (name+"Window"), exists=True ) ):
deleteUI( name+"Window" )
window( (name+'Window'), w=100, h=50 )
showWindow( (name+'Window') )
paneLayout( configuration='single' )
button( l='test', rgb=[ 0.5, 0.5, 0.5] )
setParent(u=1)