maya Creating Maya UI Basic UI example [Python]


Example

The Maya GUI toolkit creates a variety of UI elements in a simple, imperative form. There are basic commands to create and edit GUI widgets; the widgets are identified by a unique string name.

All gui commands take the same basic form: you supply a command type and the string name of the object you want to work on or create, along with flags that specify the look or behavior of the widget. So, for example, to create a button you'd use:

 cmds.button('my_button', label = 'my label')

This will create a new gui button. To edit the button you'd use the same command with the edit flag (the short version is just e). So you could change the label of the button like this:

cmds.button('my_button', e=True, label = 'a different label')

and you can query the current value of a property with the query or q flag:

cmds.button(`my button`, q=True, label=True)
# 'a different label'