Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / MEL / Adding rows/columns to Layout while Script is running - possible ?
  RSS 2.0 ATOM  

Adding rows/columns to Layout while Script is running - possible ?
Rate this thread
 
40824
 
Permlink of this thread  
avatar
  • mkda
  • Posted: 17 March 2010 03:19 AM
  • Total Posts: 2
  • Joined: 10 November 2008 03:18 AM

Hello,

currently I’m working on a MEL script which should list up some cameras I created with the help of that script.

In a seperate frameLayout, the script should list up all settings from every camera I had created while the script is running.

In that frameLayout, there are 6 columns (title of the camera, option1,option2 ... ).

If I push the “Create Camera” button, I want to get this new created camera also listed up in that list so I thought about editing the rowColumnLayout, which contains all the columns and cameras. But there doesn’t seem any way to do that. I also tried simply to add a new rowLayout which has “setParent frameLayoutXY” at the end. But with that the new rowLayout will be added to the end of my whole window…

What can I do?

Here is some example code:

window -title "testwindow" -width 600 -height 300;
columnLayout;
frameLayout -label "Checkliste"
 
-collapsable true
 
-collapse true
 
-borderStyle "etchedIn"
 
checkListe;
 
rowLayout -numberOfColumns 6;
 
text -label "Stereokamera";
 
text -label "1";
 
text -label "2";
 
text -label "3";
 
text -label "4";
 
text -label "5";
 
setParent ..;
setParent ..;
button -label "OK" -command "changeList"
showWindow;

proc changeList()
{

// doesn't work
 
frameLayout -edit
 rowLayout 
-numberOfColumns 6 ;
 
button -label "test";
 
button -label "test";
 
button -label "test";
 
button -label "test";
 
button -label "test";
 
button -label "test";
 
checkListe;

// doesn't work neither

 
rowLayout -numberOfColumns 6 ;
 
button -label "test";
 
button -label "test";
 
button -label "test";
 
button -label "test";
 
button -label "test";
 
button -label "test";
 
setParent checkListe;



}

Can somebody help me?

thx



Replies: 0
avatar
  • samavan
  • Posted: 19 April 2010 12:51 AM

First of all, when working with UI this is very important to give a name to all the parts of your UI.

window, columnLayout, rowLayout, Button, frameLayout etc…

It will help you if you would like to edit something on the fly with a script.

I read your script and I asking to myself “why from the moon, he is editing something he didn’t give a name??”

Anyway.

Simple rule to remember is : You cannot edit a FrameLayout if you already attached some stuff to it.

If the button are children of you rowLayout, then you need to edit the rowlayout if you want to attach more buttons or edit each button’s label.

But now if you want to create a new buttons list, better for you to kill mister rowLayout (and bye bye to his children too) and then to build a new rowLayout.
But do not forget to parent it to the frameLayout. o_<

For that reason names are important!!

Look and try the following example :

window -title "testwindow" -width 600 -height 300;
 
columnLayout;
 
frameLayout  -label "Checklist"
   
-collapsable true
   
-collapse true
   
-borderStyle "etchedIn"
   
frameLayoutCheckList;
  
rowLayout -numberOfColumns 6 rowLayoutCheckList;
  
text -label "StereoCamera";
  
text -label "1";
  
text -label "2";
  
text -label "3";
  
text -label "4";
  
text -label "5";
   
setParent ..;
 
setParent ..;
 
 
button -label "OK" -command "changeList"
 
showWindow;

proc changeList()
{
 deleteUI rowLayoutCheckList
;
  
rowLayout -p frameLayoutCheckList -numberOfColumns 6 rowLayoutCheckList;
  
text -label "A";
  
text -label "B";
  
text -label "C";
  
text -label "D";
  
text -label "E";
  
text -label "5";


}


Portfolio_small.png

Replies: 0