.md →
AnnotationWidget API#
Bases: AnyWidget
Annotation input widget with buttons, keyboard shortcuts, gamepad, and speech-to-text.
This widget provides a UI input surface for annotation workflows. It does
NOT render the object being annotated — the notebook handles content
display and reacts to the action traitlet.
The action_timestamp traitlet changes on every action, even repeated
ones, so observe always fires.
Examples:
import marimo as mo
from wigglystuff import AnnotationWidget
widget = mo.ui.anywidget(AnnotationWidget())
widget
Source code in wigglystuff/annotation.py
Synced traitlets#
| Traitlet | Type | Notes |
|---|---|---|
action |
str |
Name of the most recently triggered action (e.g., accept, fail). |
action_timestamp |
float |
Timestamp (ms since epoch) of the latest action; changes on every trigger so observe always fires, even for repeats. |
note |
str |
Free-form note text, populated by typing or speech-to-text. |
listening |
bool |
True while speech-to-text is actively transcribing. |
disabled |
bool |
When True, all input controls are inert. |
show_save |
bool |
Toggles visibility and availability of the footer Save button. |
actions |
list[str] |
Ordered list of main action button labels. Defaults to ["previous", "accept", "fail", "defer"]. |
keyboard_mapping |
dict[str, str] |
Maps keys to action names. By default, action buttons are mapped to number keys in order (1, 2, ...), with s for save and m for mic. The special target mic toggles the speech-to-text microphone. |
gamepad_mapping |
dict[str, str] |
Maps gamepad button indices (as strings) to action names. By default, action buttons are mapped to gamepad buttons in order (0, 1, ...), followed by save and mic. The mic target works here too. |
debounce_ms |
int |
Minimum interval between accepted action triggers, in milliseconds. |
width |
int |
Widget width in pixels. |