gistwidget
Labs — This is an experimental project. And not recommended for production use.
Share anywidgets via GitHub Gists. Two functions, zero config.
Build a widget in a notebook, publish it to a gist, and anyone can load it back — JS, CSS, Python traitlets and all.
Install
uv add gistwidget
# or
pip install gistwidget
Quickstart
Load a widget someone already published:
import gistwidget
Widget = gistwidget.load("4de49e3627f06804c53d235f004d41c0")
Widget()
Publish your own:
import os
import anywidget
import traitlets
import gistwidget
class CounterWidget(anywidget.AnyWidget):
_esm = """
export default {
render({ model, el }) {
let btn = document.createElement("button");
btn.innerText = `Count: ${model.get("count")}`;
btn.addEventListener("click", () => {
model.set("count", model.get("count") + 1);
model.save_changes();
});
model.on("change:count", () => {
btn.innerText = `Count: ${model.get("count")}`;
});
el.appendChild(btn);
}
};
"""
count = traitlets.Int(0).tag(sync=True)
result = gistwidget.publish(
CounterWidget,
description="Counter widget",
token=os.getenv("GITHUB_TOKEN"),
)
print(result.html_url)
API
gistwidget.load(gist_id, *, token=None)
Load a widget class from a GitHub Gist.
| Parameter | Type | Description |
|---|---|---|
gist_id |
str |
Gist ID, user/id, or full URL |
token |
str | None |
GitHub token (only needed for private gists) |
Returns a type[anywidget.AnyWidget] — the widget class, not an instance. Call it to create one.
gistwidget.publish(widget, *, gist_id=None, description="", public=False, token=None)
Publish a widget to a GitHub Gist.
| Parameter | Type | Description |
|---|---|---|
widget |
type | instance |
An AnyWidget class or instance |
gist_id |
str | None |
Update an existing gist (omit to create new) |
description |
str |
Gist description |
public |
bool |
Public or secret gist |
token |
str |
GitHub token (required) |
Returns a GistResult with .gist_id and .html_url.
GistResult
@dataclass
class GistResult:
gist_id: str
html_url: str
GistError
Raised on API errors or invalid input. Has an optional .status_code attribute for HTTP errors.
What gets stored in the gist
| File | Contents | When |
|---|---|---|
widget.js |
Your _esm JavaScript |
Always |
widget.css |
Your _css stylesheet |
If _css is set |
widget.py |
Traitlet definitions | If the widget has custom traitlets |
When loading, all three are reassembled into a working widget class.
Notebooks
The notebooks/ directory contains marimo notebooks:
load_widget.py— Interactive loader: paste a gist ID, get a live widgetpublish_widget.py— Defines a drawing-canvas widget and publishes it
Development
uv pip install -e ".[dev]"
pytest tests/
Metadata
Release files for gistwidget 0.1.2
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 |
|---|---|---|---|---|
| gistwidget-0.1.2.tar.gz | 9.1 kB | Without provenance | Details for gistwidget-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gistwidget-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for gistwidget-0.1.2-py3-none-any.whl |
Total release size: 15.9 kB
Release files / gistwidget-0.1.2.tar.gz
| Download URL | gistwidget-0.1.2.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
21a7cc6a6b476d6828204804567adfd2abb44603bf4ce31abf5df24448df3308
|
|
BLAKE2b-256 checksum How to use checksums |
fa7e0a2e4ff7f471b89e7a845e39f9241327b91bf526d9ebfb3b08f8bcff285d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / gistwidget-0.1.2-py3-none-any.whl
| Download URL | gistwidget-0.1.2-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6cc9f670e1b9ca558ba9f8dec4a206c0b4c0ff0cec3195a4e4f04e079e3b9d30
|
|
BLAKE2b-256 checksum How to use checksums |
5fbcbe58955e17f70095abb7d3851852c3ea4f6aa19c90fc2539ff5c3c8025d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for gistwidget 0.1.2
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.