All great user interfaces start with window. In this example, we'll be creating a simple window and using the text label control to add a simple message.
We'll end up with something like the following:
Start by creating a new file in your scripts directory and naming it basic Window.py
.
Add the following code:
import maya.cmds as cmds def showUI(): myWin = cmds.window(title="Simple Window", widthHeight=(300, 200)) cmds.columnLayout() cmds.text(label="Hello, Maya!") cmds.showWindow(myWin) showUI()
If you run the script, you should see a small window containing the text Hello, Maya!.
To create a window, you'll need to use the window command.
myWin = cmds.window(title="Simple Window", widthHeight=(300, 200))
While all of the arguments are optional, there are a few that you'll generally want to include by default. Here, we're setting the title to "Simple Window" and the size of the window to 300 pixels wide by 200 pixels tall. Also...