simple, custom Jupyter widgets
Project description
anywidget ![](https://pypi-camo.freetls.fastly.net/2866365682b6db9e2941e80c72a7a87587d0f191/68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f6d616e7a742f616e797769646765742f6d61696e2f646f63732f7075626c69632f66617669636f6e2e737667)
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()
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
Project details
Release history Release notifications | RSS feed
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.0.5.tar.gz
(11.8 kB
view hashes)
Built Distribution
anywidget-0.0.5-py3-none-any.whl
(21.3 kB
view hashes)
Close
Hashes for anywidget-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b68d5178505bcc43ad3f999b56a52f5809dadaabed0fb1eeac07d6e91aebe69 |
|
MD5 | 7b8edd4ffc716ed715e89f6533f1eef1 |
|
BLAKE2b-256 | 6c81f65ad50fc91ee379885b8c91be8c0c16ca2811e6fe007223a990e5f75f5e |