pywry.widget¶
Jupyter widget classes using anywidget for inline notebook rendering.
Base Widget¶
pywry.widget.PyWryWidget
¶
Bases: EmittingWidget
Fallback widget used when anywidget is not installed.
The fallback preserves the public API shape of the notebook widgets so imports remain valid, but interactive behavior is unavailable.
Initialize fallback widget.
Attributes¶
Functions¶
on
¶
on(event_type: str, callback: Callable[..., Any], label: str | None = None) -> PyWryWidget
Register an event handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_type
|
str
|
Event name to subscribe to. |
required |
callback
|
Callable[..., Any]
|
Callback that would handle the event in a real anywidget runtime. |
required |
label
|
str or None
|
Ignored (accepted for API compatibility with |
None
|
Returns:
| Type | Description |
|---|---|
PyWryWidget
|
Self for method chaining. |
Notes
This is a no-op in fallback mode.
emit
¶
Send an event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_type
|
str
|
Event name that would be emitted to the frontend. |
required |
data
|
dict[str, Any] | None
|
Payload that would be delivered with the event. |
None
|
Notes
This is a no-op in fallback mode.
from_html
classmethod
¶
from_html(content: str, callbacks: dict[str, Callable[[dict[str, Any], str, str], Any]] | None = None, theme: str = 'dark', width: str = '100%', height: str = '500px', toolbars: list | None = None, modals: list | None = None) -> PyWryWidget
Build a fallback widget; ignores callbacks/toolbars/modals.
alert
¶
alert(message: str, alert_type: Literal['info', 'success', 'warning', 'error', 'confirm'] = 'info', title: str | None = None, duration: int | None = None, callback_event: str | None = None, position: Literal['top-right', 'top-left', 'bottom-right', 'bottom-left'] = 'top-right') -> None
Show a toast notification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
The message to display. |
required |
alert_type
|
str
|
Alert type: 'info', 'success', 'warning', 'error', or 'confirm'. |
'info'
|
title
|
str
|
Optional title for the toast. |
None
|
duration
|
int
|
Auto-dismiss duration in ms. Defaults based on type. |
None
|
callback_event
|
str
|
Event name to emit when confirm dialog is answered. |
None
|
position
|
str
|
Toast position: 'top-right', 'top-left', 'bottom-right', 'bottom-left'. |
'top-right'
|
Plotly Widget¶
pywry.widget.PyWryPlotlyWidget
¶
Bases: PyWryWidget
Fallback Plotly widget when anywidget is not available.
Initialize fallback widget.
Attributes¶
Functions¶
emit
¶
Send an event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_type
|
str
|
Event name that would be emitted to the frontend. |
required |
data
|
dict[str, Any] | None
|
Payload that would be delivered with the event. |
None
|
Notes
This is a no-op in fallback mode.
alert
¶
alert(message: str, alert_type: Literal['info', 'success', 'warning', 'error', 'confirm'] = 'info', title: str | None = None, duration: int | None = None, callback_event: str | None = None, position: Literal['top-right', 'top-left', 'bottom-right', 'bottom-left'] = 'top-right') -> None
Show a toast notification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
The message to display. |
required |
alert_type
|
str
|
Alert type: 'info', 'success', 'warning', 'error', or 'confirm'. |
'info'
|
title
|
str
|
Optional title for the toast. |
None
|
duration
|
int
|
Auto-dismiss duration in ms. Defaults based on type. |
None
|
callback_event
|
str
|
Event name to emit when confirm dialog is answered. |
None
|
position
|
str
|
Toast position: 'top-right', 'top-left', 'bottom-right', 'bottom-left'. |
'top-right'
|
on
¶
on(event_type: str, callback: Callable[..., Any], label: str | None = None) -> PyWryWidget
Register an event handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_type
|
str
|
Event name to subscribe to. |
required |
callback
|
Callable[..., Any]
|
Callback that would handle the event in a real anywidget runtime. |
required |
label
|
str or None
|
Ignored (accepted for API compatibility with |
None
|
Returns:
| Type | Description |
|---|---|
PyWryWidget
|
Self for method chaining. |
Notes
This is a no-op in fallback mode.
from_html
classmethod
¶
from_html(content: str, callbacks: dict[str, Callable[[dict[str, Any], str, str], Any]] | None = None, theme: str = 'dark', width: str = '100%', height: str = '500px', toolbars: list | None = None, modals: list | None = None) -> PyWryWidget
Build a fallback widget; ignores callbacks/toolbars/modals.
AG Grid Widget¶
pywry.widget.PyWryAgGridWidget
¶
Bases: PyWryWidget
Fallback AG Grid widget when anywidget is not available.
Initialize fallback widget.
Attributes¶
Functions¶
update_columns
¶
Update columns (no-op in fallback).
update_grid
¶
Update grid (no-op in fallback).
emit
¶
Send an event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_type
|
str
|
Event name that would be emitted to the frontend. |
required |
data
|
dict[str, Any] | None
|
Payload that would be delivered with the event. |
None
|
Notes
This is a no-op in fallback mode.
alert
¶
alert(message: str, alert_type: Literal['info', 'success', 'warning', 'error', 'confirm'] = 'info', title: str | None = None, duration: int | None = None, callback_event: str | None = None, position: Literal['top-right', 'top-left', 'bottom-right', 'bottom-left'] = 'top-right') -> None
Show a toast notification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
The message to display. |
required |
alert_type
|
str
|
Alert type: 'info', 'success', 'warning', 'error', or 'confirm'. |
'info'
|
title
|
str
|
Optional title for the toast. |
None
|
duration
|
int
|
Auto-dismiss duration in ms. Defaults based on type. |
None
|
callback_event
|
str
|
Event name to emit when confirm dialog is answered. |
None
|
position
|
str
|
Toast position: 'top-right', 'top-left', 'bottom-right', 'bottom-left'. |
'top-right'
|
on
¶
on(event_type: str, callback: Callable[..., Any], label: str | None = None) -> PyWryWidget
Register an event handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_type
|
str
|
Event name to subscribe to. |
required |
callback
|
Callable[..., Any]
|
Callback that would handle the event in a real anywidget runtime. |
required |
label
|
str or None
|
Ignored (accepted for API compatibility with |
None
|
Returns:
| Type | Description |
|---|---|
PyWryWidget
|
Self for method chaining. |
Notes
This is a no-op in fallback mode.
from_html
classmethod
¶
from_html(content: str, callbacks: dict[str, Callable[[dict[str, Any], str, str], Any]] | None = None, theme: str = 'dark', width: str = '100%', height: str = '500px', toolbars: list | None = None, modals: list | None = None) -> PyWryWidget
Build a fallback widget; ignores callbacks/toolbars/modals.