How to use the @lumino/widgets.Widget.attach function in @lumino/widgets

To help you get started, we’ve selected a few @lumino/widgets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyterlab / jupyterlab / tests / test-notebook / src / notebooktools.spec.ts View on Github external
context0 = await initNotebookContext();
      panel0 = NBTestUtils.createNotebookPanel(context0);
      NBTestUtils.populateNotebook(panel0.content);
      context1 = await initNotebookContext();
      panel1 = NBTestUtils.createNotebookPanel(context1);
      NBTestUtils.populateNotebook(panel1.content);
      tracker = new NotebookTracker({ namespace: 'notebook' });
      await tracker.add(panel0);
      await tracker.add(panel1);
      notebookTools = new NotebookTools({ tracker });
      tabpanel = new TabPanel();
      tabpanel.addWidget(panel0);
      tabpanel.addWidget(panel1);
      tabpanel.addWidget(notebookTools);
      tabpanel.node.style.height = '800px';
      Widget.attach(tabpanel, document.body);
      // Give the posted messages a chance to be handled.
      await sleep();
    });
github jupyterlab / jupyterlab / tests / test-completer / src / widget.spec.ts View on Github external
it('should emit a signal when an item is selected', () => {
        let anchor = createEditorWidget();
        let options: Completer.IOptions = {
          editor: anchor.editor,
          model: new CompleterModel()
        };
        let value = '';
        let listener = (sender: any, selected: string) => {
          value = selected;
        };
        options.model!.setOptions(['foo', 'bar']);
        Widget.attach(anchor, document.body);

        let widget = new Completer(options);

        widget.selected.connect(listener);
        Widget.attach(widget, document.body);
        MessageLoop.sendMessage(widget, Widget.Msg.UpdateRequest);
        expect(value).to.equal('');
        widget.selectActive();
        expect(value).to.equal('foo');
        widget.dispose();
        anchor.dispose();
      });
    });
github jupyterlab / jupyterlab / tests / test-apputils / src / widgettracker.spec.ts View on Github external
it('should emit when the current widget has been updated', async () => {
        const widget = createWidget();
        let promise = signalToPromise(tracker.currentChanged);

        Widget.attach(widget, document.body);
        focus(widget);
        void tracker.add(widget);
        await promise;
        widget.dispose();
      });
    });
github jupyterlab / jupyterlab / tests / test-apputils / src / widgettracker.spec.ts View on Github external
it('should not emit when a widget has been injected', async () => {
        const one = createWidget();
        const two = createWidget();
        let total = 0;
        let promise = testEmission(tracker.currentChanged, {
          find: () => {
            return total === 1;
          }
        });

        tracker.widgetAdded.connect(() => {
          total++;
        });
        void tracker.add(one);
        void tracker.inject(two);
        Widget.attach(two, document.body);
        focus(two);
        Widget.detach(two);
        await promise;
        one.dispose();
        two.dispose();
      });
    });
github jupyterlab / jupyterlab / tests / test-logconsole / src / widget.spec.ts View on Github external
it('emits when console is shown', () => {
      const s = new SignalLogger(logConsole.sourceDisplayed);
      const loggerA = registry.getLogger('A');
      loggerA.log({ type: 'text', data: 'A1', level: 'warning' });
      logConsole.source = 'A';
      logConsole.hide();
      Widget.attach(logConsole, document.body);
      expect(s.args).toEqual([]);
      logConsole.show();
      expect(s.args).toEqual([{ source: 'A', version: 1 }]);
      s.dispose();
    });
github jupyterlab / jupyterlab / tests / test-apputils / src / vdom.spec.ts View on Github external
it('should work with a null model', async () => {
        const widget = new TestWidgetNoModel();
        Widget.attach(widget, document.body);
        await framePromise();
        const span = widget.node.firstChild as HTMLElement;
        expect(span.textContent).to.equal('No model!');
      });
    });
github jupyterlab / jupyterlab / tests / test-cells / src / inputarea.spec.ts View on Github external
it('should render the widget', () => {
        const widget = new InputArea({ model });
        const rendered = new Widget();
        Widget.attach(widget, document.body);
        widget.renderInput(rendered);
        expect(rendered.isAttached).to.equal(true);
        widget.dispose();
      });
    });
github jupyterlab / jupyterlab / tests / test-cells / src / widget.spec.ts View on Github external
it('should focus the cell editor', async () => {
        const widget = new LogBaseCell().initializeState();
        Widget.attach(widget, document.body);
        widget.activate();
        await framePromise();
        expect(widget.methods).toContain('onActivateRequest');
        await framePromise();
        expect(widget.editor.hasFocus()).toEqual(true);
        widget.dispose();
      });
    });
github jupyterlab / jupyterlab / tests / test-completer / src / widget.spec.ts View on Github external
charWidth: editor.charWidth,
          line: position.line,
          text: 'a'
        };

        model.original = request;
        model.cursor = { start: 0, end: 1 };
        model.setOptions(['abc', 'abd', 'abe', 'abi']);

        let widget = new Completer({ model, editor: code.editor });
        widget.hide();
        expect(called).to.equal(false);
        widget.visibilityChanged.connect(() => {
          called = true;
        });
        Widget.attach(widget, document.body);
        MessageLoop.sendMessage(widget, Widget.Msg.UpdateRequest);

        await framePromise();
        expect(called).to.equal(true);
        widget.dispose();
        code.dispose();
        panel.dispose();
      });
    });
github jupyterlab / jupyterlab / packages / apputils / src / dialog.ts View on Github external
return promises.then(() => {
      Widget.attach(this, this._host);
      return promise.promise;
    });
  }