Skip to content

pywry.types

Type definitions for window positions, sizes, effects, cookies, and monitors.


Position & Size Types

pywry.types.PhysicalSize dataclass

PhysicalSize(width: int, height: int)

Physical size in pixels.

Functions

to_dict

to_dict() -> dict[str, int]

Serialize to dictionary for IPC.

from_dict classmethod

from_dict(data: dict[str, Any]) -> PhysicalSize

Deserialize from dictionary.

pywry.types.LogicalSize dataclass

LogicalSize(width: float, height: float)

Logical size (scaled by DPI factor).

Functions

to_dict

to_dict() -> dict[str, float]

Serialize to dictionary for IPC.

from_dict classmethod

from_dict(data: dict[str, Any]) -> LogicalSize

Deserialize from dictionary.

pywry.types.PhysicalPosition dataclass

PhysicalPosition(x: int, y: int)

Physical position in pixels.

Functions

to_dict

to_dict() -> dict[str, int]

Serialize to dictionary for IPC.

from_dict classmethod

from_dict(data: dict[str, Any]) -> PhysicalPosition

Deserialize from dictionary.

pywry.types.LogicalPosition dataclass

LogicalPosition(x: float, y: float)

Logical position (scaled by DPI factor).

Functions

to_dict

to_dict() -> dict[str, float]

Serialize to dictionary for IPC.

from_dict classmethod

from_dict(data: dict[str, Any]) -> LogicalPosition

Deserialize from dictionary.


Enumerations

pywry.types.Theme

Bases: Enum

Window theme mode.

pywry.types.TitleBarStyle

Bases: Enum

Title bar style options.

pywry.types.UserAttentionType

Bases: Enum

User attention request type.

pywry.types.CursorIcon

Bases: Enum

Cursor icon options.

pywry.types.Effect

Bases: Enum

Visual effects for window background (platform-specific).

pywry.types.EffectState

Bases: Enum

Effect state options.

pywry.types.ProgressBarStatus

Bases: Enum

Progress bar status options.

pywry.types.SameSite

Bases: Enum

Cookie SameSite attribute.


Typed Dicts

pywry.types.Effects

Bases: TypedDict

Visual effects configuration.

pywry.types.ProgressBarState

Bases: TypedDict

Progress bar state configuration.


Data Classes

pywry.types.Cookie dataclass

Cookie(name: str, value: str, domain: str = '', path: str = '/', secure: bool = False, http_only: bool = False, same_site: SameSite = LAX, expires: float | None = None)

HTTP Cookie representation.

Functions

to_dict

to_dict() -> dict[str, Any]

Serialize to dictionary for IPC.

from_dict classmethod

from_dict(data: dict[str, Any]) -> Cookie

Deserialize from dictionary.

pywry.types.Monitor dataclass

Monitor(name: str | None, size: PhysicalSize, position: PhysicalPosition, scale_factor: float)

Display monitor information.

Functions

to_dict

to_dict() -> dict[str, Any]

Serialize to dictionary for IPC.

from_dict classmethod

from_dict(data: dict[str, Any]) -> Monitor

Deserialize from dictionary.


Serialization Helpers

pywry.types.serialize_size

serialize_size(size: SizeType) -> dict[str, Any]

Serialize a size value for IPC.

pywry.types.serialize_position

serialize_position(position: PositionType) -> dict[str, Any]

Serialize a position value for IPC.

pywry.types.serialize_effects

serialize_effects(effects: Effects) -> dict[str, Any]

Serialize effects configuration for IPC.

pywry.types.serialize_progress_bar

serialize_progress_bar(state: ProgressBarState) -> dict[str, Any]

Serialize progress bar state for IPC.


See the Native Menus guide for usage.

pywry.types.PredefinedMenuItemKind

Bases: Enum

Predefined OS-level menu item kinds.

pywry.types.MenuItemConfig dataclass

MenuItemConfig(id: str, text: str, handler: Callable[..., Any] = None, enabled: bool = True, accelerator: str | None = None)

Configuration for a regular menu item.

Every clickable menu item must have a handler. Pass a callable that accepts (data, event_type, label).

PARAMETER DESCRIPTION
id

Unique identifier used for event routing.

TYPE: str

text

Display text for the item.

TYPE: str

handler

Click handler — receives (data, event_type, label).

TYPE: Callable DEFAULT: None

enabled

Whether the item is interactive.

TYPE: bool DEFAULT: True

accelerator

Keyboard shortcut (e.g. "CmdOrCtrl+S").

TYPE: str or None DEFAULT: None

Functions

to_dict

to_dict() -> dict[str, Any]

Serialize to dictionary for IPC.

pywry.types.CheckMenuItemConfig dataclass

CheckMenuItemConfig(id: str, text: str, handler: Callable[..., Any] = None, enabled: bool = True, checked: bool = False, accelerator: str | None = None)

Configuration for a check (toggle) menu item.

Every check menu item must have a handler.

PARAMETER DESCRIPTION
id

Unique identifier used for event routing.

TYPE: str

text

Display text.

TYPE: str

handler

Click handler — receives (data, event_type, label).

TYPE: Callable DEFAULT: None

enabled

Whether the item is interactive.

TYPE: bool DEFAULT: True

checked

Initial checked state.

TYPE: bool DEFAULT: False

accelerator

Keyboard shortcut.

TYPE: str or None DEFAULT: None

Functions

to_dict

to_dict() -> dict[str, Any]

Serialize to dictionary for IPC.

pywry.types.IconMenuItemConfig dataclass

IconMenuItemConfig(id: str, text: str, handler: Callable[..., Any] = None, enabled: bool = True, icon: bytes | None = None, icon_width: int = 16, icon_height: int = 16, native_icon: str | None = None, accelerator: str | None = None)

Configuration for a menu item with an icon.

Every icon menu item must have a handler.

PARAMETER DESCRIPTION
id

Unique identifier used for event routing.

TYPE: str

text

Display text.

TYPE: str

handler

Click handler — receives (data, event_type, label).

TYPE: Callable DEFAULT: None

enabled

Whether the item is interactive.

TYPE: bool DEFAULT: True

icon

RGBA icon bytes (use pytauri.image.Image format).

TYPE: bytes or None DEFAULT: None

icon_width

Icon width in pixels.

TYPE: int DEFAULT: 16

icon_height

Icon height in pixels.

TYPE: int DEFAULT: 16

native_icon

Native OS icon name (macOS only), e.g. "Add", "Folder".

TYPE: str or None DEFAULT: None

accelerator

Keyboard shortcut.

TYPE: str or None DEFAULT: None

Functions

to_dict

to_dict() -> dict[str, Any]

Serialize to dictionary for IPC.

pywry.types.PredefinedMenuItemConfig dataclass

PredefinedMenuItemConfig(kind_name: PredefinedMenuItemKind, text: str | None = None)

Configuration for a predefined OS menu item.

PARAMETER DESCRIPTION
kind_name

Which predefined item to create.

TYPE: PredefinedMenuItemKind

text

Override text (some predefined items accept this).

TYPE: str or None DEFAULT: None

Functions

to_dict

to_dict() -> dict[str, Any]

Serialize to dictionary for IPC.

pywry.types.SubmenuConfig dataclass

SubmenuConfig(id: str, text: str, enabled: bool = True, items: list[MenuItemKindConfig] | None = None)

Configuration for a submenu.

PARAMETER DESCRIPTION
id

Unique submenu identifier.

TYPE: str

text

Display text for the submenu entry.

TYPE: str

enabled

Whether the submenu is interactive.

TYPE: bool DEFAULT: True

items

Child menu item configurations.

TYPE: list DEFAULT: None

Functions

to_dict

to_dict() -> dict[str, Any]

Serialize to dictionary for IPC.

collect_handlers

collect_handlers() -> dict[str, Callable[..., Any]]

Walk children and return {item_id: handler} for every handled item.

pywry.types.MenuConfig dataclass

MenuConfig(id: str, items: list[MenuItemKindConfig])

Top-level menu configuration.

PARAMETER DESCRIPTION
id

Menu identifier.

TYPE: str

items

Menu item configurations.

TYPE: list

Functions

to_dict

to_dict() -> dict[str, Any]

Serialize to dictionary for IPC.

collect_handlers

collect_handlers() -> dict[str, Callable[..., Any]]

Walk the full item tree and return {item_id: handler}.

Recursively descends into submenus. Only items with a handler attribute are included (e.g. PredefinedMenuItemConfig is skipped).

from_dict classmethod

from_dict(data: dict[str, Any]) -> MenuConfig

Deserialize from dictionary.


Tray Types

See the System Tray guide for usage.

pywry.types.MouseButton

Bases: Enum

Mouse button identifiers.

pywry.types.MouseButtonState

Bases: Enum

Mouse button press state.

pywry.types.TrayIconConfig dataclass

TrayIconConfig(id: str, tooltip: str | None = None, title: str | None = None, icon: bytes | None = None, icon_width: int = 32, icon_height: int = 32, menu: MenuConfig | None = None, menu_on_left_click: bool = True, on_click: Callable[..., Any] | None = None, on_double_click: Callable[..., Any] | None = None, on_right_click: Callable[..., Any] | None = None)

Configuration for a system tray icon.

PARAMETER DESCRIPTION
id

Unique tray icon identifier.

TYPE: str

tooltip

Hover tooltip text.

TYPE: str or None DEFAULT: None

title

Tray icon title (macOS menu bar text).

TYPE: str or None DEFAULT: None

icon

RGBA icon bytes.

TYPE: bytes or None DEFAULT: None

icon_width

Icon width in pixels.

TYPE: int DEFAULT: 32

icon_height

Icon height in pixels.

TYPE: int DEFAULT: 32

menu

Menu to attach to the tray icon.

TYPE: MenuConfig or None DEFAULT: None

menu_on_left_click

Whether left click shows the menu.

TYPE: bool DEFAULT: True

on_click

Handler for single-click events.

TYPE: Callable or None DEFAULT: None

on_double_click

Handler for double-click events.

TYPE: Callable or None DEFAULT: None

on_right_click

Handler for right-click events.

TYPE: Callable or None DEFAULT: None

Functions

to_dict

to_dict() -> dict[str, Any]

Serialize to dictionary for IPC.