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 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

on

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

Register an event handler (no-op in fallback).

emit

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

Send an event (no-op in fallback).

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.

PARAMETER DESCRIPTION
message

The message to display.

TYPE: str

alert_type

Alert type: 'info', 'success', 'warning', 'error', or 'confirm'.

TYPE: str DEFAULT: 'info'

title

Optional title for the toast.

TYPE: str DEFAULT: None

duration

Auto-dismiss duration in ms. Defaults based on type.

TYPE: int DEFAULT: None

callback_event

Event name to emit when confirm dialog is answered.

TYPE: str DEFAULT: None

position

Toast position: 'top-right', 'top-left', 'bottom-right', 'bottom-left'.

TYPE: str DEFAULT: '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 (no-op in fallback).

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.

PARAMETER DESCRIPTION
message

The message to display.

TYPE: str

alert_type

Alert type: 'info', 'success', 'warning', 'error', or 'confirm'.

TYPE: str DEFAULT: 'info'

title

Optional title for the toast.

TYPE: str DEFAULT: None

duration

Auto-dismiss duration in ms. Defaults based on type.

TYPE: int DEFAULT: None

callback_event

Event name to emit when confirm dialog is answered.

TYPE: str DEFAULT: None

position

Toast position: 'top-right', 'top-left', 'bottom-right', 'bottom-left'.

TYPE: str DEFAULT: 'top-right'

on

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

Register an event handler (no-op in fallback).

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 (no-op in fallback).

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.

PARAMETER DESCRIPTION
message

The message to display.

TYPE: str

alert_type

Alert type: 'info', 'success', 'warning', 'error', or 'confirm'.

TYPE: str DEFAULT: 'info'

title

Optional title for the toast.

TYPE: str DEFAULT: None

duration

Auto-dismiss duration in ms. Defaults based on type.

TYPE: int DEFAULT: None

callback_event

Event name to emit when confirm dialog is answered.

TYPE: str DEFAULT: None

position

Toast position: 'top-right', 'top-left', 'bottom-right', 'bottom-left'.

TYPE: str DEFAULT: 'top-right'

on

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

Register an event handler (no-op in fallback).

set_content

set_content(content: str) -> None

Set content.

_repr_html_

_repr_html_() -> str

HTML representation.