Help with setParent

Help with setParent

samunawa
Enthusiast Enthusiast
611 Views
2 Replies
Message 1 of 3

Help with setParent

samunawa
Enthusiast
Enthusiast

Hi there. I'm trying to get to grips with the setParent command but I can't get it to work! Heres my example code that I'm testing this with:

 

 

string $window = `window -t "Shape Spawner" -wh 560 500`;
        rowLayout -numberOfColumns 2;
            button -label "Delete All" -command "select -cl; MTselAll; doDelete";
        setParent..;
    setParent..;
    gridLayout -numberOfColumns 8 -cellWidthHeight 70 50;
            symbolButton -image "polySphere.xpm" -command "polySphere;"; 
            symbolButton -image "polyCube.xpm" -command "polyCube;";
            symbolButton -image "polyCylinder.xpm" -command "polyCylinder;";
            symbolButton -image "polyCone.xpm" -command "polyCone;";
            symbolButton -image "polyPlane.xpm" -command "polyPlane;";
            symbolButton -image "polyTorus.xpm" -command "polyTorus;";
            symbolButton -image "polyPyramid.xpm" -command "polyPyramid;";
            symbolButton -image "polyPipe.xpm" -command "polyPipe;";
        setParent..;
    setParent..;
showWindow $window

And heres whats happening:

 

c7f715e2e2854161b013d7a87105bbf1

 

I need the "delete all" button to be ontop but I cant get this working. Do I have to create a string which defines what the 'top' is and implement that into my setParent? Thanks.

 

0 Likes
Accepted solutions (1)
612 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

Hi samunawa

 

The problem isn't in the way you are using setParent, but its actually because you are using the wrong layout type. A rowLayout is used to place items in a row next to one another. What you need is a columnLayout which puts things in a column on top of one another, like this:

 

 

string $window = `window -t "Shape Spawner" -wh 560 500`;

// columnLayout puts items on top of one another
columnLayout -adjustableColumn true;

// First item in the columnLayout
button -label "Delete All" -command "select -cl; MTselAll; doDelete";

// Second Element in the columnLayout
gridLayout -numberOfColumns 8 -cellWidthHeight 70 50;
symbolButton -image "polySphere.xpm" -command "polySphere;";
symbolButton -image "polyCube.xpm" -command "polyCube;";
symbolButton -image "polyCylinder.xpm" -command "polyCylinder;";
symbolButton -image "polyCone.xpm" -command "polyCone;";
symbolButton -image "polyPlane.xpm" -command "polyPlane;";
symbolButton -image "polyTorus.xpm" -command "polyTorus;";
symbolButton -image "polyPyramid.xpm" -command "polyPyramid;";
symbolButton -image "polyPipe.xpm" -command "polyPipe;";
setParent ..;
setParent ..;

showWindow $window

 

 

The -adjustableColumn true part makes the column stretch to fit its parent container, so in this case it makes the button stretch with the window.

 

Its also worth pointing out that strictly speaking you don't actually need the last two setParent calls, unless you are planning on adding more UI after the gridLayout. However it is good practice to always pop back to the parent layout to avoid confusion when you come to modify the code at a later date.

 

Hope this helps

 

Mike.

Message 3 of 3

samunawa
Enthusiast
Enthusiast

Ah yes you've explained it better than my teacher haha, thank you 🙂

0 Likes