Is it possible to embed a GUI built with GUI build

2019-02-25 02:00发布

问题:

I've created some GUI parts with GUI Builder and I wanted to embed them in panels of my scripts, instead of adding them directly in the app. But apparently, a such code doesn't work:

  var app = UiApp.createApplication();
  var vp = app.createVerticalPanel();
  vp.add(app.loadComponent("myGUI"));
  app.add(vp);
  return app;

Is it (or will it be) possible to add GUI's from GUI Builder in other containers than app?

Thanks!

回答1:

You can do it like in this example

function doGet() {
  var app = UiApp.createApplication()
  var Panel = app.createAbsolutePanel().setStyleAttribute('background', 'beige').setPixelSize(400,600);
  var label = app.createLabel('gui test')
  var gui = app.loadComponent('MyGui')
  Panel.add(app.getElementById('VerticalPanel1'))
  Panel.add(label)
  app.add(Panel)
  return app
  }

and the GUI looks like this :

Instead of adding the component I added the panel (in this example 'VerticalPanel1') that contains all the other widgets.

The result looks like this :