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.3.8.tar.gz (148.9 kB view details)

Uploaded Source

Built Distribution

yjs_widgets-0.3.8-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yjs_widgets-0.3.8.tar.gz
  • Upload date:
  • Size: 148.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for yjs_widgets-0.3.8.tar.gz
Algorithm Hash digest
SHA256 24cbb20c9f782fe886fec0d8be5de1156fd598cd18eb43475a83752b6f6b61de
MD5 f926c8b6d3a0b021d73fb5a18d3e408f
BLAKE2b-256 f3d0240897646f66896b0e8e98b8e0da43b7a43ab3ae4a9d17d4c6bd236b5bb8

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: yjs_widgets-0.3.8-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for yjs_widgets-0.3.8-py3-none-any.whl
Algorithm Hash digest
SHA256 3fe0016ac220b066831ca04e49fbec9f3dc4cd05c5886fdff28fa5265565230c
MD5 790ed9164a0c69ac5714e66032779e6c
BLAKE2b-256 a4b5585b1fafb0607ae524727befb2a6bf9ea906a8e33268b2da4ca978bf83e8

See more details on using hashes here.

Provenance

Supported by

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