Skip to content

System Events (pywry:*)

Lifecycle Events (JS → Python)

Event Payload Description
pywry:ready {} Window/widget initialized and ready
pywry:result any Data from window.pywry.result(data)
pywry:message any Data from window.pywry.message(data)
pywry:content-request {widget_type, window_label, reason} Window requests content
pywry:disconnect {} Widget disconnected (browser/inline mode)
pywry:close {label} Window close requested

Window Events (JS → Python)

Event Payload Description
window:closed {label} Window was closed
window:hidden {label} Window was hidden

Content & Styling (Python → JS)

Event Payload Description
pywry:set-content {id?, selector?, text?, html?} Update element text/HTML
pywry:set-style {id?, selector?, styles: {}} Update element CSS
pywry:inject-css {css, id?} Inject CSS (id for replacement)
pywry:remove-css {id} Remove injected CSS by id
pywry:update-html {html} Replace entire page content
pywry:update-theme {theme} Switch theme (dark, light, or system)

Theme Broadcast (JS → Python)

Event Payload Description
pywry:theme-update {mode, original} Broadcast when the frontend resolves a theme change — fires after the user toggles dark/light or when system mode resolves to the concrete light/dark choice. mode is the resolved theme (dark / light); original is the request (dark / light / system).

Notifications & Actions (Python → JS)

Event Payload Description
pywry:alert {message, type?, title?, duration?, position?, callback_event?} Toast notification
pywry:download {content, filename, mimeType?} Trigger file download
pywry:download-csv {filename, data: [[row]], headers?} Trigger a CSV download — the frontend serialises data as CSV and streams it through the same download pipeline as pywry:download. Used by the Plotly export-data flow.
pywry:navigate {url} Navigate to URL
pywry:refresh {} Request content refresh
pywry:cleanup {} Cleanup resources (native mode)

Alert types: info, success, warning, error, confirm

Alert positions: top-right (default), top-left, bottom-right, bottom-left