Sixteen progressively complex examples covering every major feature of the framework — from a one-liner Hello World to multi-page apps with live updates, theming, and modal dialogs.
python examples/01_hello_world.py
# then open http://localhost:6502
Example 08 exports a static HTML file instead of starting a server.
ww.serve(). Establishes the script-mode
pattern you will use in every subsequent example.
@slider.on_change) and demonstrates
real-time multi-widget updates over SSE.
[2, 1]).
ww.theme() call restyles every component on the page.
ww.export(). No
server needed — open the output directly in a browser.
@app.page() decorators to
register three routes (home, about, contact) with ww.nav() for
cross-page navigation. Each handler receives a PageContext
with the same API as module-level functions.
ww.tabs() and collapsible sections with
ww.accordion(). Shows how context managers
organise content within each pane or section.
ww.sidebar() as a context manager and ww.nav()
for navigation links.
datasets parameter. Includes summary metrics and a chart-type
selector dropdown.
ww.plot() with dict-based data and x /
y column specifications — pandas-like plotting without
the dependency.
widget.update() for in-place DOM patches
and the callback → SSE → DOM update cycle.
ww.grid("1fr 1fr 1fr") for a CSS Grid containing nested
cards with metrics, charts, and text.
ww.modal() as a
context manager with a toast-triggering callback.
If you are new to webwrench, work through the examples in this order:
| Stage | Examples | Focus |
|---|---|---|
| 1. Basics | 01 – 03 | Output elements, charts, columns, themes |
| 2. Layouts | 04, 10, 11, 15 | Dashboards, tabs, sidebars, grids |
| 3. Interactivity | 02, 05, 14, 16 | Widgets, callbacks, live updates, modals |
| 4. Data | 06, 12, 13 | Tables, multi-dataset charts, DataFrame plots |
| 5. Advanced | 07 – 09 | Theming, static export, multi-page apps |