Widgets#
widgets.py — Interactive overlay widget classes.
Each widget has a .callbacks (CallbackRegistry). Register handlers via:
@rect.on_changed # every drag frame
def live(event): ...
@rect.on_release # once on mouseup
def done(event): ...
@rect.on_click
def clicked(event): ...
rect.x = 40 # moves widget, sends targeted update to JS
rect.x # always reflects current JS position
- class anyplotlib.widgets.Widget(wtype, push_fn, **kwargs)[source]#
Bases:
objectBase class for all overlay widgets.
- Parameters:
wtype (str)
push_fn (Callable)
- set(_push=True, **kwargs)[source]#
Update properties. Sends a targeted event_json update to JS (not a full panel push). Fires on_changed callbacks.
Use _push=False internally (e.g. _update_from_js) to avoid echo.
- Parameters:
_push (bool)
- Return type:
None
- class anyplotlib.widgets.RectangleWidget(push_fn, *, x, y, w, h, color='#00e5ff')[source]#
Bases:
Widget
- class anyplotlib.widgets.CircleWidget(push_fn, *, cx, cy, r, color='#00e5ff')[source]#
Bases:
Widget
- class anyplotlib.widgets.AnnularWidget(push_fn, *, cx, cy, r_outer, r_inner, color='#00e5ff')[source]#
Bases:
Widget
- class anyplotlib.widgets.CrosshairWidget(push_fn, *, cx, cy, color='#00e5ff')[source]#
Bases:
Widget
- class anyplotlib.widgets.PolygonWidget(push_fn, *, vertices, color='#00e5ff')[source]#
Bases:
Widget