Skip to main content

A JupyterLab extension for widgets based on Yjs.

Project description

JupyterLab extension for widgets based on Yjs

Requirements

  • JupyterLab == 4.0.0b0

Installation

You can install yjs-widgets using pip:

pip install yjs-widgets

Usage

import { IJupyterYModel } from './types';
import { JupyterYModel } from './model';
import { IJupyterYWidgetManager } from './notebookrenderer/types';
import {
  JupyterFrontEnd,
  JupyterFrontEndPlugin
} from '@jupyterlab/application';

class MyWidget {
  constructor(yModel: IJupyterYModel, node: HTMLElement) {
    this.yModel = yModel;
    this.node = node;
    yModel.sharedModel.attrsChanged.connect(() => {
      this._attrsChanged();
    });
    node.textContent = 'Hello world!';
  }

  _attrsChanged(): void {
    const foo: string = this.yModel.sharedModel.getAttr('foo') as string;
    const bar: string = this.yModel.sharedModel.getAttr('bar') as string;
    this.node.textContent = `foo=${foo}, bar=${bar}`;
  }

  yModel: IJupyterYModel;
  node: HTMLElement;
}

export const foo: JupyterFrontEndPlugin<void> = {
  id: 'foo:bar',
  autoStart: true,
  requires: [IJupyterYWidgetManager],
  activate: (app: JupyterFrontEnd, wm: IJupyterYWidgetManager): void => {
    wm.registerWidget('MyWidget', JupyterYModel, MyWidget);
  }
};

Contributing

yjs-widgets is an open-source project, and contributions are always welcome. If you would like to contribute, please fork the repository and submit a pull request.

See CONTRIBUTING for dev installation instructions.

License

yjs-widgets is licensed under the BSD 3-Clause License. See the LICENSE file for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yjs_widgets-0.5.1.tar.gz (153.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yjs_widgets-0.5.1-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file yjs_widgets-0.5.1.tar.gz.

File metadata

  • Download URL: yjs_widgets-0.5.1.tar.gz
  • Upload date:
  • Size: 153.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for yjs_widgets-0.5.1.tar.gz
Algorithm Hash digest
SHA256 ff382697588b72c6f46a53299872664fe027e5ee75302e7740bb30df274d7b4a
MD5 747ab11634fcd1a98c36e131a3e70e6e
BLAKE2b-256 9ee3daec85faa11c03ed0add4320b96429e2a3d694db057629c7a0d5f4a49ac8

See more details on using hashes here.

File details

Details for the file yjs_widgets-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: yjs_widgets-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for yjs_widgets-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fda87bdc2b05b436d7c2ad9f74e829eead5c27b79b0d18a3b8747f4c53d51337
MD5 edff267e821cb91e0080e5cbdc3ebdad
BLAKE2b-256 7cb0884a0d8aa155cbf8256559100f1e9a67b3d5ea32c4feca1e37c895502aec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page