anywidget 
custom jupyter widgets made easy
- create widgets without complicated cookiecutter templates
- publish to PyPI like any other Python package
- prototype within
.ipynbor.pyfiles - 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
-epip option allows one to modify the Python code in-place. Restart the kernel in order to see the changes. - the
--symlinkargument 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
Metadata
Release files for anywidget 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| anywidget-0.1.0.tar.gz | 11.8 kB | Without provenance | Details for anywidget-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| anywidget-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for anywidget-0.1.0-py3-none-any.whl |
Total release size: 33.1 kB
Release files / anywidget-0.1.0.tar.gz
| Download URL | anywidget-0.1.0.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f9501dfc7aabc1f6ee8ddc9feafe85bae4e9418d8c17485666cdd556322e9176
|
|
BLAKE2b-256 checksum How to use checksums |
e861adb4fa5d544db5c31783408b575816a8f4f2dfb2fd9e14a95db9150a10a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / anywidget-0.1.0-py3-none-any.whl
| Download URL | anywidget-0.1.0-py3-none-any.whl |
|---|---|
| Size | 21.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b94243cd0b4e3486f32a74976c49bbabd5506e5d1c7b1468fdd24dc79e7729d9
|
|
BLAKE2b-256 checksum How to use checksums |
742c8df8dc42ea8cf3ebfeb0e788580af6b1e1edbbbf347b0572187edcf3e578
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Security for anywidget 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.