How do I add listbox to tab1 and something else in tab2?

119 Views Asked by At

Here is my code and I can't seem to get Listbox or anything to show up. I found the main code posted on other forums.

I only added the Listbox code however I cannot seem to see any of my objects visible, not sure what’s happening.

var dlg = new Window ("dialog", "Abas", [0,0,0,0]);

dlg.size = [240, 120]

dlg.location = [415, 230]

var tpanel = dlg.add ("tabbedpanel" ,[10,10,0,0],);

tpanel.size = [220,100];

dlg.location = [10, 10];

var general = tpanel.add ("tab", [0,0,0,0], "Color");

var general1 = dlg.add('tabbedpanel')
var boo_tab = general1.add('tab', u, "Create Solids");
    

var t = boo_tab.add("statictext", undefined, "Hello", {multiline:false});
t.text = "Create Solids";

var listBox = tpanel.add("listbox", undefined, []);
listBox.selection = 0;
listBox.size = [300, 100];
listBox.add("item", "Create 2 solids");
listBox.add("item", "Create Solid");
listBox.add("item", "Create Solid dlgith fractual noise");


var images = tpanel.add ("tab", undefined, "Levels");

var img_options = images.add ("panel", undefined, "Image Options");

var buttons = dlg.add ("group");

buttons.add ("button", undefined, "Export", {name: "ok"});

buttons.add ("button", undefined, "Cancel");

var images1 = tpanel.add ("tab", undefined, "Curves");

var img_options = images1.add ("panel", undefined, "Image Options");

var buttons = dlg.add ("group");

buttons.add ("button", undefined, "Export", {name: "ok"});

buttons.add ("button", undefined, "Cancel");

tpanel.selection = 0;

dlg.center();

dlg.show ();
1

There are 1 best solutions below

0
On

There appears to be quite a few things wrong with this code and it is difficult to figure out exactly what you are hoping to achieve.

The first thing that I'm noticing is that you are adding some objects to the tabbed panel instead of the tabs themselves.

For instance, you can't add listbox to tpanel because tpanel will only be expecting tab objects. Instead add listbox to either a group or a tab object. For instance, you could add it to your boo_tab object like so:

var listBox = boo_tab.add("listbox", undefined, []);

The same is true with images1. It cannot be added to tpanel. So you will need to choose where you want it.

I can't tell for certain if it was your intention to create a second tabbed panel general1 under the first one or if you just wanted it to be a new tab. If you wanted a new tabbed panel you are going to want to put both tabbed panels in their own groups.

It also looks like you want to add some buttons to the bottom. I believe, in order for this to work the way you want, you will also need to put tpanel in its own group.

I would like to suggest that while you are learning, you only add one item at a time. This way, if something goes wrong, you only have to troubleshoot one thing at a time and it is easier to discover where mistakes have been made.