I need to resize my buttons as it is taking up space.
I draw a custom 6 button mock image onto the original image. I want all my buttons to be layed out like that 3 buttons on each line.
var w = new Window('dialog', "ALL IN ONE TOOLBOX 2022", u);
w.orientation = 'column';
// w.margins = 5;
// w.spacing = 10;
w.alignChildren = ['fill', 'fill'];
myButton = w.add( "button", undefined, "Create Solid", { name: "ok" } );
myButton0 = w.add("button", undefined, "Create Null", {name:"ok"});
myButton1 = w.add("button", undefined, "Create shape", {name:"ok"});
myButton2 = w.add("button", undefined, "Parallel light", {name:"ok"});
myButton3 = w.add("button", undefined, "Spot Light", {name:"ok"});
myButton4 = w.add("button", undefined, "Point Light", {name:"ok"});
myButton5 = w.add("button", undefined, "Ambient Light", {name:"ok"});
myButton6 = w.add("button", undefined, "Regular Light", {name:"ok"});
myButton7 = w.add("button", undefined, "Create Camera", {name:"ok"});
myButton8 = w.add("button", undefined, "Create Ajustment", {name:"ok"})
i even added this dont work still remains same
myButton = w.add("button", [50, 30, 150, 60], "Create Solid", {name:"ok"});
myButton0 = w.add("button", [50, 30, 150, 60], "Create Null", {name:"ok"});
myButton1 = w.add("button", [50, 30, 150, 60], "Create shape", {name:"ok"});
myButton2 = w.add("button", [50, 30, 150, 60], "Parallel light", {name:"ok"});
myButton3 = w.add("button", [50, 30, 150, 60], "Spot Light", {name:"ok"});
myButton4 = w.add("button", [50, 30, 150, 60], "Point Light", {name:"ok"});
myButton5 = w.add("button", [50, 30, 150, 60], "Ambient Light", {name:"ok"});
myButton6 = w.add("button", [50, 30, 150, 60], "Regular Light", {name:"ok"});
myButton7 = w.add("button", [50, 30, 150, 60], "Create Camera", {name:"ok"});
myButton8 = w.add("button", [50, 30, 150, 60], "Create Ajustment", {name:"ok"});
I believe what you are looking for is 'groups'. The code below gave me the following layout:
The very first group is set to
columns
to allow stacking of the subsequent groups. All of the other groups are set torow
to allow the three buttons to be aligned.Set the top group's
alignCenter
to be["center","center"]
in order for the rows to be center aligned.In order to get the buttons to be the same size, I set their
preferredSize.width
to be large enough to allow space for the button with the largest amount of text, which happened to be "Create Adjustment" and with a value that happened to be 116. I placed this in thebtnWidth
variable. This may need to be changed if you add more buttons and need to accommodate one with larger text.Hopefully this will be enough to set you in the right direction!