pywry.models¶
Core Pydantic models for content, window configuration, and events.
Window Mode¶
Theme Mode¶
pywry.models.ThemeMode
¶
Window Configuration¶
pywry.models.WindowConfig
¶
Bases: BaseModel
Configuration for window creation.
Fields are split into two groups:
Application-level fields — used by PyWry's template and content pipeline
(theme, enable_plotly, aggrid_theme, etc.).
Builder-level fields — forwarded to WebviewWindowBuilder.build() in
the subprocess. Fields marked (build-only) can only be set at window
creation time; they have no post-creation set_* equivalent.
Attributes¶
plotly_theme
class-attribute
instance-attribute
¶
plotly_theme: Literal['plotly', 'plotly_white', 'plotly_dark', 'ggplot2', 'seaborn', 'simple_white'] = 'plotly_dark'
aggrid_theme
class-attribute
instance-attribute
¶
_BUILDER_FIELDS
class-attribute
¶
_BUILDER_FIELDS: set[str] = {'resizable', 'decorations', 'always_on_top', 'always_on_bottom', 'transparent', 'fullscreen', 'maximized', 'focused', 'visible', 'shadow', 'skip_taskbar', 'content_protected', 'user_agent', 'incognito', 'initialization_script', 'drag_and_drop'}
Functions¶
builder_kwargs
¶
Return non-default builder kwargs for WebviewWindowBuilder.build().
Only includes fields whose values differ from the Pydantic defaults,
keeping the IPC payload minimal. title and inner_size are
always handled separately by the caller.
validate_dimensions
¶
validate_dimensions() -> WindowConfig
Validate min dimensions don't exceed actual dimensions.
HTML Content¶
pywry.models.HtmlContent
¶
Event Models¶
Generic Event¶
pywry.models.GenericEvent
¶
Bases: BaseModel
Generic event for custom event handling.
Attributes¶
Functions¶
validate_event_type_format
classmethod
¶
Validate event type matches namespace:event-name pattern.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
The event type string to validate.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The validated event type. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the event type is invalid. |
Result Event¶
pywry.models.ResultEvent
¶
Plotly Click Event¶
pywry.models.PlotlyClickEvent
¶
Plotly Select Event¶
pywry.models.PlotlySelectEvent
¶
Bases: BaseModel
Plotly selection event data.
Plotly Hover Event¶
pywry.models.PlotlyHoverEvent
¶
Plotly Relayout Event¶
pywry.models.PlotlyRelayoutEvent
¶
Validation Functions¶
pywry.models.validate_event_type
¶
Validate event type matches namespace:event-name pattern or is wildcard.
| PARAMETER | DESCRIPTION |
|---|---|
event_type
|
The event type string to validate.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if valid, False otherwise. |
Grid Events¶
pywry.models.GridSelectionEvent
¶
pywry.models.GridRowClickEvent
¶
Event Payloads¶
pywry.models.ResultPayload
¶
pywry.models.GenericEventPayload
¶
Bases: BaseModel
Payload for pywry_event command.
Attributes¶
Functions¶
validate_event_type_format
classmethod
¶
Validate event type matches namespace:event-name pattern.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
The event type string to validate.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The validated event type. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the event type is invalid. |
pywry.models.FilePathPayload
¶
pywry.models.WindowClosedPayload
¶
pywry.models.AlertPayload
¶
Bases: BaseModel
Enhanced alert event payload for pywry:alert system event.
Supports typed toast notifications with auto-dismiss, persistence, and confirmation dialogs with callbacks.
Attributes¶
message
class-attribute
instance-attribute
¶
type
class-attribute
instance-attribute
¶
type: Literal['info', 'success', 'warning', 'error', 'confirm'] = Field(default='info', description='Alert type determining icon and behavior')
title
class-attribute
instance-attribute
¶
duration
class-attribute
instance-attribute
¶
duration: int | None = Field(default=None, description='Auto-dismiss duration in ms (None uses type default)')
callback_event
class-attribute
instance-attribute
¶
callback_event: str | None = Field(default=None, description="Event to emit on confirm/cancel (for type='confirm')")
position
class-attribute
instance-attribute
¶
position: Literal['top-right', 'bottom-right', 'bottom-left', 'top-left'] = Field(default='top-right', description='Toast position on screen')