pywry.commands¶
Tauri IPC command handlers and event dispatch.
Command Dispatch¶
pywry.commands.dispatch_command
¶
Dispatch a command to its handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
str
|
The command name. |
required |
payload
|
dict of str to Any
|
The command payload. |
required |
Returns:
| Type | Description |
|---|---|
dict of str to Any
|
Response dict from the handler. |
pywry.commands.register_commands
¶
Register IPC commands with pytauri.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commands
|
Commands
|
pytauri Commands instance. |
required |
pywry.commands.serialize_response
¶
Serialize a response to JSON string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
dict of str to Any
|
The response dict. |
required |
Returns:
| Type | Description |
|---|---|
str
|
JSON string. |
Event Handlers¶
pywry.commands.handle_window_close
¶
Handle window close event - aggressive cleanup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The window label. |
required |
Returns:
| Type | Description |
|---|---|
dict of str to Any
|
Response dict. |
pywry.commands.handle_pywry_result
¶
Handle result from JavaScript execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The window label. |
required |
data
|
dict of str to Any
|
The result data. |
required |
Returns:
| Type | Description |
|---|---|
dict of str to Any
|
Response dict indicating success/failure. |
pywry.commands.handle_pywry_event
¶
Handle generic events from JavaScript.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The window label. |
required |
event_data
|
dict of str to Any
|
The event data including type and payload. |
required |
Returns:
| Type | Description |
|---|---|
dict of str to Any
|
Response dict indicating success/failure. |
pywry.commands.handle_plotly_event
¶
Handle Plotly-specific events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The window label. |
required |
event_data
|
dict of str to Any
|
The event data with plotly_event and data fields. |
required |
Returns:
| Type | Description |
|---|---|
dict of str to Any
|
Response dict indicating success/failure. |
pywry.commands.handle_aggrid_event
¶
Handle AG Grid-specific events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The window label. |
required |
event_data
|
dict of str to Any
|
The event data with grid_event and data fields. |
required |
Returns:
| Type | Description |
|---|---|
dict of str to Any
|
Response dict indicating success/failure. |
pywry.commands.handle_open_file
¶
Open a file with the system's default application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The file path to open. |
required |
Returns:
| Type | Description |
|---|---|
dict of str to Any
|
Response dict indicating success/failure. |
pywry.commands.handle_open_url
¶
Open a URL in the system's default browser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL to open. |
required |
Returns:
| Type | Description |
|---|---|
dict of str to Any
|
Response dict indicating success/failure. |
Payload Models¶
pywry.commands.GenericEvent
¶
Bases: BaseModel
Generic event envelope for custom event handling.
Attributes:
| Name | Type | Description |
|---|---|---|
event_type |
str
|
Event name in |
data |
Any
|
Arbitrary event payload forwarded from the frontend. |
window_label |
str
|
Window identifier that emitted the event. |
timestamp |
datetime
|
Event creation time. |
Functions¶
validate_event_type_format
classmethod
¶
Validate event type matches namespace:event-name pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
str
|
The event type string to validate. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The validated event type. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the event type is invalid. |