Skip to main content

anywidget

PyPI License Open In Colab

custom jupyter widgets made easy

  • create widgets without complicated cookiecutter templates
  • publish to PyPI like any other Python package
  • prototype within .ipynb or .py files
  • run in Jupyter, JupyterLab, Google Colab, VSCode, and more
  • develop (optionally) with Vite for instant HMR

Installation

pip install anywidget

Usage

import anywidget
import traitlets

ESM = """
export function render(view) {
  let count = () => view.model.get("value");
  let btn = document.createElement("button");
  btn.innerHTML = `count is ${count()}`;
  btn.addEventListener("click", () => {
    view.model.set("value", count() + 1);
    view.model.save_changes();
  });
  view.model.on("change:value", () => {
    btn.innerHTML = `count is ${count()}`;
  });
  view.el.appendChild(btn);
}
"""

class CounterWidget(anywidget.AnyWidget):
    _esm = ESM
    value = traitlets.Int(0).tag(sync=True)

CounterWidget()
button indicating the number of times it has been clicked

Development

pip install -e .

If you are using the classic Jupyter Notebook you need to install the nbextension:

jupyter nbextension install --py --symlink --sys-prefix anywidget
jupyter nbextension enable --py --sys-prefix anywidget

Note for developers:

  • the -e pip option allows one to modify the Python code in-place. Restart the kernel in order to see the changes.
  • the --symlink argument on Linux or OS X allows one to modify the JavaScript code in-place. This feature is not available with Windows.

For developing with JupyterLab:

jupyter labextension develop --overwrite anywidget

Release

npm version [major|minor|patch]
git tag -a vX.X.X -m "vX.X.X"
git push --follow-tags

Download files

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

Source Distribution

anywidget-0.1.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

anywidget-0.1.0-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file anywidget-0.1.0.tar.gz.

File metadata

  • Download URL: anywidget-0.1.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for anywidget-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f9501dfc7aabc1f6ee8ddc9feafe85bae4e9418d8c17485666cdd556322e9176
MD5 88b4bab729154036a972fd92e5ae2f4f
BLAKE2b-256 e861adb4fa5d544db5c31783408b575816a8f4f2dfb2fd9e14a95db9150a10a7

See more details on using hashes here.

File details

Details for the file anywidget-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: anywidget-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for anywidget-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b94243cd0b4e3486f32a74976c49bbabd5506e5d1c7b1468fdd24dc79e7729d9
MD5 1ae3654afc9b20c50bdfaf42d10164d1
BLAKE2b-256 742c8df8dc42ea8cf3ebfeb0e788580af6b1e1edbbbf347b0572187edcf3e578

See more details on using hashes here.

Release history Release notifications | RSS feed

0.11.0

2 files

0.10.0

2 files

0.9.21

2 files

0.9.20

2 files

0.9.19

2 files

0.9.18

2 files

0.9.17

2 files

0.9.16

2 files

0.9.15

2 files

0.9.14

2 files

0.9.13

2 files

0.9.12

2 files

0.9.11

2 files

0.9.10

2 files

0.9.9

2 files

0.9.8

2 files

0.9.7

2 files

0.9.6

2 files

0.9.5

2 files

0.9.4

2 files

0.9.3

2 files

0.9.2

2 files

0.9.1

2 files

0.9.0

2 files

0.8.1

2 files

0.8.0

2 files

0.7.1

2 files

0.7.0

2 files

0.6.5

2 files

0.6.4

2 files

0.6.3

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.2

2 files

0.1.1

2 files

This release

0.1.0 This release

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

0.0.0

2 files

Supported by

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