Skip to content

pywry.widget

Jupyter widget classes using anywidget for inline notebook rendering.


Base Widget

pywry.widget.PyWryWidget

PyWryWidget(**kwargs: Any)

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

_label instance-attribute

_label = f'w-{hex[:8]}'

content instance-attribute

content = get('content', '')

_handlers instance-attribute

_handlers: dict[str, list[Callable[..., Any]]] = {}

label property

label: str

Get widget label.

Functions

on

on(event_type: str, callback: Callable[..., Any]) -> None

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
Notes

This is a no-op in fallback mode.

emit

emit(event_type: str, data: dict[str, Any] | None = None) -> None

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.

set_content

set_content(content: str) -> None

Set content.

_repr_html_

_repr_html_() -> str

HTML representation.

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

PyWryPlotlyWidget(**kwargs: Any)

Bases: PyWryWidget

Fallback Plotly widget when anywidget is not available.

Initialize fallback widget.

Attributes

_label instance-attribute

_label = f'w-{hex[:8]}'

content instance-attribute

content = get('content', '')

_handlers instance-attribute

_handlers: dict[str, list[Callable[..., Any]]] = {}

label property

label: str

Get widget label.

Functions

emit

emit(event_type: str, data: dict[str, Any] | None = None) -> None

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]) -> None

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
Notes

This is a no-op in fallback mode.

set_content

set_content(content: str) -> None

Set content.

_repr_html_

_repr_html_() -> str

HTML representation.


AG Grid Widget

pywry.widget.PyWryAgGridWidget

PyWryAgGridWidget(**kwargs: Any)

Bases: PyWryWidget

Fallback AG Grid widget when anywidget is not available.

Initialize fallback widget.

Attributes

_label instance-attribute

_label = f'w-{hex[:8]}'

content instance-attribute

content = get('content', '')

_handlers instance-attribute

_handlers: dict[str, list[Callable[..., Any]]] = {}

label property

label: str

Get widget label.

Functions

update_data

update_data(data: Any) -> None

Update grid data (no-op in fallback).

update_columns

update_columns(columns: list[dict[str, Any]]) -> None

Update columns (no-op in fallback).

update_grid

update_grid(data: Any = None, columns: list[dict[str, Any]] | None = None) -> None

Update grid (no-op in fallback).

emit

emit(event_type: str, data: dict[str, Any] | None = None) -> None

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]) -> None

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
Notes

This is a no-op in fallback mode.

set_content

set_content(content: str) -> None

Set content.

_repr_html_

_repr_html_() -> str

HTML representation.