How to use the @lumino/widgets.Widget 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-application / src / layoutrestorer.spec.ts View on Github external
it('should save data', async () => {
        const ready = new PromiseDelegate();
        const restorer = new LayoutRestorer({
          connector: new StateDB(),
          first: ready.promise,
          registry: new CommandRegistry()
        });
        const currentWidget = new Widget();
        // The `fresh` attribute is only here to check against the return value.
        const dehydrated: ILabShell.ILayout = {
          fresh: false,
          mainArea: { currentWidget: null, dock: null, mode: null },
          leftArea: {
            currentWidget,
            collapsed: true,
            widgets: [currentWidget]
          },
          rightArea: { collapsed: true, currentWidget: null, widgets: null }
        };
        restorer.add(currentWidget, 'test-one');
        ready.resolve(void 0);
        await restorer.restored;
        await restorer.save(dehydrated);
        const layout = await restorer.fetch();
github jupyterlab / lumino / examples / example-datastore / src / widget.ts View on Github external
constructor(datastore: Datastore, record: string) {
    super();
    this.addClass('content');
    this._store = datastore;
    this._record = record;

    // Get initial values for the editor
    let editorTable = this._store.get(EDITOR_SCHEMA);
    let initialValue = editorTable.get(record)!.text;
    let readOnly = editorTable.get(record)!.readOnly;

    // Set up the DOM structure
    this._editorWidget = new Widget();
    this._checkWidget = new Widget();
    this._checkWidget.node.style.height = `${this._toolbarHeight}px`;
    this._checkWidget.addClass('read-only-check');
    this._checkWidget.node.textContent = 'Read Only';
    this._check = document.createElement('input');
    this._check.type = 'checkbox';
    this._check.checked = readOnly;
    this._checkWidget.node.appendChild(this._check);

    this.addWidget(this._checkWidget);
    this.addWidget(this._editorWidget);

    // Listen to changes in the checkbox.
    this._check.onchange = this._onChecked.bind(this);

    // Create the editor instance.
    this._editor = CodeMirror(this._editorWidget.node, {
github jupyterlab / jupyterlab / tests / test-application / src / shell.spec.ts View on Github external
it('should be a no-op if the widget is not in the left area', () => {
      const widget = new Widget();
      widget.id = 'foo';
      expect(widget.isVisible).to.equal(false);
      shell.activateById('foo');
      expect(widget.isVisible).to.equal(false);
    });
github jupyterlab / jupyterlab / tests / test-application / src / shell.spec.ts View on Github external
it('should close all of the widgets in the main area', () => {
      const foo = new Widget();
      foo.id = 'foo';
      shell.add(foo, 'main');
      const bar = new Widget();
      bar.id = 'bar';
      shell.add(bar, 'main');
      shell.closeAll();
      expect(foo.parent).to.equal(null);
      expect(bar.parent).to.equal(null);
    });
  });
github jupyterlab / jupyterlab / tests / test-statusbar / src / statusbar.spec.ts View on Github external
it('should only show if isActive returns true', () => {
        const item = new Widget();
        statusBar.registerStatusItem('item', {
          item,
          isActive: () => false
        });
        expect(item.isHidden).to.be.true;
      });
github jupyterlab / jupyterlab / tests / test-inspector / src / inspector.spec.ts View on Github external
it('should fire when a source updates', () => {
        const widget = new TestInspectorPanel();
        widget.source = new TestInspectable();
        expect(widget.methods).to.not.contain('onInspectorUpdate');
        (widget.source.inspected as any).emit({ content: new Widget() });
        expect(widget.methods).to.contain('onInspectorUpdate');
      });
    });
github jupyterlab / jupyterlab / tests / test-docmanager / src / widgetmanager.spec.ts View on Github external
protected createNewWidget(
    context: DocumentRegistry.Context
  ): IDocumentWidget {
    const content = new Widget();
    const widget = new DocumentWidget({ content, context });
    widget.addClass('WidgetFactory');
    return widget;
  }
}
github jupyterlab / jupyterlab / tests / test-docmanager / src / manager.spec.ts View on Github external
protected createNewWidget(
    context: DocumentRegistry.Context,
    source: CloneTestWidget
  ): CloneTestWidget {
    return new CloneTestWidget({
      context,
      content: new Widget(),
      count: source ? source.counter + 1 : 0
    });
  }
}
github jupyterlab / jupyterlab / packages / apputils / src / dialog.ts View on Github external
createHeader(title: Header): Widget {
      let header: Widget;
      if (typeof title === 'string') {
        header = new Widget({ node: document.createElement('span') });
        header.node.textContent = title;
      } else {
        header = ReactWidget.create(title);
      }
      header.addClass('jp-Dialog-header');
      Styling.styleNode(header.node);
      return header;
    }
github jupyterlab / jupyterlab / packages / apputils / src / dialog.ts View on Github external
createFooter(buttons: ReadonlyArray): Widget {
      let footer = new Widget();
      footer.addClass('jp-Dialog-footer');
      each(buttons, button => {
        footer.node.appendChild(button);
      });
      Styling.styleNode(footer.node);
      return footer;
    }