A simple Interface
|
|
Back to -> Week 9 - User Interface
A Simple Interface
Maya has functions to create windows that popup and are capable of including controls that you can attach to functions in Maya or that you write your self.
The simplest window command is:
window -visible true -title "Test Window" TestWindow1
But of course it would be better if the window actually did something! Lets add create a window with a button to make a sphere.
window -widthHeight 380 200 -title "Create a Sphere!" spherePalette;
columnLayout -columnAttach "right" 10 -rowSpacing 10 -columnWidth 300;
button -label "Create a Sphere" -c "sphere";
showWindow spherePalette;
Next, we can make a window that operates on an object using a slider....
$sphere = `sphere`;
window -widthHeight 380 200 -title "Create a Sphere!" spherePalette;
columnLayout -columnAttach "right" 10 -rowSpacing 10 -columnWidth 300;
attrFieldSliderGrp -min -20 -max 20.0 -at ($sphere[0] + ".ty");
showWindow spherePalette;
Something to note here is that, when testing a window, you may get an error.
If the window has been created but not shown, it will give an error when you try to run it again.
To fix this use the showWindow command, close, the window and then run it again.
Now let's put it in a procedure and make a MEL button:
global proc sphereMaker() {
$sphere = `sphere`;
window -widthHeight 380 200 -title "Create a Sphere!" spherePalette;
columnLayout -columnAttach "right" 10 -rowSpacing 10 -columnWidth 300;
attrFieldSliderGrp -min -20 -max 20.0 -at ($sphere[0] + ".ty");
showWindow spherePalette;
}
|
A simple Interface
|