Anywidget demo: drawdata¶
drawdata is a small
anywidget — a self-contained ES module
that draws onto a <canvas>. Click and drag in the panel
below to scribble points; press a number key (1–4) before
drawing to switch the active class.
This page is static — there is no Python kernel running.
The widget renders because marimo-book extracts the inlined
ES module from marimo export's output and mounts it via a
~150-line shim (marimo_book.js). See Anywidgets for the
full pipeline.
What you can and can't do statically¶
- ✅ The widget renders — anywidget's
_esmtrait is inlined as adata:URL, so no kernel and no CDN are required. - ✅ All client-side interaction works — drawing, brush colours, the canvas itself.
- ❌ The drawn
datacannot flow into a downstream Python cell. That needs a kernel.
For genuine Python reactivity (drawn points → live DataFrame →
live plot) flip the chapter to mode: wasm in book.yml. See
the WASM demo for what that looks like.