Skip to content

Question regarding JupyterLab Widgets #2

@TK-21st

Description

@TK-21st

Thank you so much for this work! We've been looking for a quick way to develop/debug JLab extensions for quite some time now, and this seems to be of great help!

I have a question regarding JupyterLab widgets, particularly those that subclass @lumino/widgets. Simply put, if we use the

As a barebone example, I was trying to see if it'd be possible to dynamically load the tutorial widget/extension (https://github.com/jupyterlab/jupyterlab_apod).

So in this case, the index.js of the APOD Widget/Extension compiles into something like

define(["require", "exports", "@jupyterlab/application", "@jupyterlab/apputils", "@lumino/widgets"], function (require, exports, application_1, apputils_1, widgets_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    ;
    class APODWidget extends widgets_1.Widget {
    ...
    }

    function active(app, palette, restorer) {
    }

    /**
     * Initialization data for the jupyterlab_apod extension.
     */
    const extension = {
        id: 'my-apod-extension',
        autoStart: true,
        requires: [apputils_1.ICommandPalette, application_1.ILayoutRestorer],
        activate: activate
    };
    exports.default = extension;

And I tried to create a JS file which looks like

return function()
{
  return {
    id: 'dynext-test-extension',
    autoStart: true,
    requires: ["jupyter.extensions.jupyterWidgetRegistry"],
    activate: function(app, widgets) {
      require.config({
        // take the widget from `unpkg.com`
        baseUrl: "/Users/tingkailiu/Projects/FFBO/JLab2/dynext-test-extension/lib"
      });

      let widget = "index";
      // note that we are using require js here to load the AMD module
      // requirejs is automatically loaded with jupyterlab-dynext.
      // * (star) selects the latest version from unpkg, and then loads the `/dist/index.js` file
      // the final URL will be something like https://unpkg.com/bqplot@^0.5.2/dist/index.js
      require([widget], function(plugin) {
        widgets.registerWidget({
            name: widget,
            version: plugin.version,
            exports: plugin
        });
      });
    }
  };
}

But it seems like jupyter.extensions.jupyterWidgetRegistry is not found and it's because I'm not using jupyterlab-manager since I'm trying to load a lab widget instead of a ipywidget.

Could you suggest a way for dynamically loading and developing jupyterlab widget/extension?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions