| Form
layout:
This is the most powerful of the layouts in terms of specifying exact
positions of controls.
Use of this layout consists of first defining the controls in the layout,
and then
using the -edit flag to set the positions of each control.
See the command reference for many options of attaching controls relative
to one another
in addition to using the window edges in this example:
window
-title "new window" -widthHeight 300 200 myWindow;
formLayout
-numberOfDivisions 100 myForm;
button
-label "make sphere" -command "sphere" myBtn1;
button
-label "make cone" -command "cone" myBtn2;
button
-label "make cube" -command "polyCube" myBtn3;
button
-label "make circle" -command "circle" myBtn4;
formLayout -edit
-attachForm
myBtn1 "top" 10
-attachForm
myBtn1 "left" 10
-attachForm
myBtn2 "top" 50
-attachForm
myBtn2 "left" 50
-attachForm
myBtn3 "top" 90
-attachForm
myBtn3 "left" 90
-attachForm
myBtn4 "bottom" 10
-attachForm
myBtn4 "right" 20
myForm;
showWindow myWindow;
Note that the
controls are referred to by the name given at the end of each control
creation command, e.g., "myBtn1". This is different than the
method used in the MSMA book and the Maya online command reference, in
which results of creation are stored in variables.
Both versions work.
One difference is if you want to query the value of the control in a different
procedure,
you will have to make the variable global. In the above example, you can
simply refer to the control name.
Another difference is if you want to be able to have multiple instances
of the window open for a specific reason. Passing the name of the new
control to a variable allows for unique naming. You would need to do the
same with the window command as well:
string
$myWindow = `window -title "new window" -widthHeight 300 200`
;
string
$myForm = `formLayout -numberOfDivisions 100`;
string
$myBtn1 = `button -label "make sphere" -command "sphere"`;
string
$myBtn2 = `button -label "make cone" -command "cone"
`;
string
$myBtn3 = `button -label "make cube" -command "polyCube"
`;
string
$myBtn4 = `button -label "make circle" -command "circle"
`;
formLayout
-edit
-attachForm
$myBtn1 "top" 10
-attachForm
$myBtn1 "left" 10
-attachForm
$myBtn2 "top" 50
-attachForm
$myBtn2 "left" 50
-attachForm
$myBtn3 "top" 90
-attachForm
$myBtn3 "left" 90
-attachForm
$myBtn4 "bottom" 10
-attachForm
$myBtn4 "right" 20
$myForm;
showWindow $myWindow;
|