Skip to content

pywry.commands

Tauri IPC command handlers and event dispatch.


Command Dispatch

pywry.commands.dispatch_command

dispatch_command(command: str, payload: dict[str, Any]) -> dict[str, Any]

Dispatch a command to its handler.

PARAMETER DESCRIPTION
command

The command name.

TYPE: str

payload

The command payload.

TYPE: dict of str to Any

RETURNS DESCRIPTION
dict of str to Any

Response dict from the handler.

pywry.commands.register_commands

register_commands(commands: Commands) -> None

Register IPC commands with pytauri.

PARAMETER DESCRIPTION
commands

pytauri Commands instance.

TYPE: Commands

pywry.commands.serialize_response

serialize_response(response: dict[str, Any]) -> str

Serialize a response to JSON string.

PARAMETER DESCRIPTION
response

The response dict.

TYPE: dict of str to Any

RETURNS DESCRIPTION
str

JSON string.


Event Handlers

pywry.commands.handle_window_close

handle_window_close(label: str) -> dict[str, Any]

Handle window close event - aggressive cleanup.

PARAMETER DESCRIPTION
label

The window label.

TYPE: str

RETURNS DESCRIPTION
dict of str to Any

Response dict.

pywry.commands.handle_pywry_result

handle_pywry_result(label: str, data: dict[str, Any]) -> dict[str, Any]

Handle result from JavaScript execution.

PARAMETER DESCRIPTION
label

The window label.

TYPE: str

data

The result data.

TYPE: dict of str to Any

RETURNS DESCRIPTION
dict of str to Any

Response dict indicating success/failure.

pywry.commands.handle_pywry_event

handle_pywry_event(label: str, event_data: dict[str, Any]) -> dict[str, Any]

Handle generic events from JavaScript.

PARAMETER DESCRIPTION
label

The window label.

TYPE: str

event_data

The event data including type and payload.

TYPE: dict of str to Any

RETURNS DESCRIPTION
dict of str to Any

Response dict indicating success/failure.

pywry.commands.handle_plotly_event

handle_plotly_event(label: str, event_data: dict[str, Any]) -> dict[str, Any]

Handle Plotly-specific events.

PARAMETER DESCRIPTION
label

The window label.

TYPE: str

event_data

The event data with plotly_event and data fields.

TYPE: dict of str to Any

RETURNS DESCRIPTION
dict of str to Any

Response dict indicating success/failure.

pywry.commands.handle_aggrid_event

handle_aggrid_event(label: str, event_data: dict[str, Any]) -> dict[str, Any]

Handle AG Grid-specific events.

PARAMETER DESCRIPTION
label

The window label.

TYPE: str

event_data

The event data with grid_event and data fields.

TYPE: dict of str to Any

RETURNS DESCRIPTION
dict of str to Any

Response dict indicating success/failure.

pywry.commands.handle_open_file

handle_open_file(path: str) -> dict[str, Any]

Open a file with the system's default application.

PARAMETER DESCRIPTION
path

The file path to open.

TYPE: str

RETURNS DESCRIPTION
dict of str to Any

Response dict indicating success/failure.

pywry.commands.handle_open_url

handle_open_url(url: str) -> dict[str, Any]

Open a URL in the system's default browser.

PARAMETER DESCRIPTION
url

The URL to open.

TYPE: str

RETURNS DESCRIPTION
dict of str to Any

Response dict indicating success/failure.


Payload Models

pywry.commands.GenericEvent

Bases: BaseModel

Generic event for custom event handling.

Functions

validate_event_type_format classmethod

validate_event_type_format(v: str) -> str

Validate event type matches namespace:event-name pattern.

PARAMETER DESCRIPTION
v

The event type string to validate.

TYPE: str

RETURNS DESCRIPTION
str

The validated event type.

RAISES DESCRIPTION
ValueError

If the event type is invalid.