add2

Tuesday, April 17, 2012

MEL Scripts for creating various GUI items

Following are few quick scipts to create MEL GUI components:


create a window
 window;

  // define the layout of controls added 
  // to the window.
  columnLayout;

   // create some text
   text -label "hello world";

 // show the window we last created
 showWindow;


Slider:
attrFieldSliderGrp -min -10 -max 10 -cw 1 20 -cw 2 1 -cw 3 70
                              -at RightLeg_CTRL.AnkelRotate
                              -l aud AFD1;

Button:
button -w 70 -h 20 -label "Select All" -ann "Select all Controls" -c selAll

Symbol Button

// create window
window;
columnLayout;
   
  // create three symbol buttons with related mel command
  symbolButton -image "circle.xpm" -command "circle";
  symbolButton -image "sphere.xpm" -command "sphere";
  symbolButton -image "cube.xpm" -command "polyCube";
showWindow;



Checkbox:
checkBox -label "IK_FK" -w 30 -h 19 -ann "Switch IK FK control"
                 -onc "l_showIKFK(\"1\")"
                 -ofc "l_showIKFK(\"0\")"
                 ik_fk_switch;

example:
// create a checkbox
$c = `checkBox -label "thingy" -onCommand "on_func" -offCommand "off_func"`;
// to get the current value of the checkBox, use the -query flag
$value = `checkBox -query -value $c`;
print("check_box value = "+ $value +"\n");



Button with IMAGE:
iconTextButton -style "iconOnly" -mw 0 -mh 0 -ann "Select Hand CTRL"
                          -image1 "bbutton.bmp" -w 20 -h 20
                          -command "SelectHandCTRL(\"Left\")" 
                           selHand_Ctrl;