pywry.types¶
Type definitions for window positions, sizes, effects, cookies, and monitors.
Position & Size Types¶
pywry.types.PhysicalSize
dataclass
¶
Physical size in pixels.
Functions¶
from_dict
classmethod
¶
from_dict(data: dict[str, Any]) -> PhysicalSize
Deserialize from dictionary.
pywry.types.PhysicalPosition
dataclass
¶
Physical position in pixels.
Functions¶
from_dict
classmethod
¶
from_dict(data: dict[str, Any]) -> PhysicalPosition
Deserialize from dictionary.
pywry.types.LogicalPosition
dataclass
¶
Logical position (scaled by DPI factor).
Functions¶
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)
pywry.types.Monitor
dataclass
¶
Monitor(name: str | None, size: PhysicalSize, position: PhysicalPosition, scale_factor: float)
Serialization Helpers¶
pywry.types.serialize_size
¶
Serialize a size value for IPC.
pywry.types.serialize_position
¶
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.
Menu Types¶
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:
|
text
|
Display text for the item.
TYPE:
|
handler
|
Click handler — receives
TYPE:
|
enabled
|
Whether the item is interactive.
TYPE:
|
accelerator
|
Keyboard shortcut (e.g.
TYPE:
|
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:
|
text
|
Display text.
TYPE:
|
handler
|
Click handler — receives
TYPE:
|
enabled
|
Whether the item is interactive.
TYPE:
|
checked
|
Initial checked state.
TYPE:
|
accelerator
|
Keyboard shortcut.
TYPE:
|
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:
|
text
|
Display text.
TYPE:
|
handler
|
Click handler — receives
TYPE:
|
enabled
|
Whether the item is interactive.
TYPE:
|
icon
|
RGBA icon bytes (use
TYPE:
|
icon_width
|
Icon width in pixels.
TYPE:
|
icon_height
|
Icon height in pixels.
TYPE:
|
native_icon
|
Native OS icon name (macOS only), e.g.
TYPE:
|
accelerator
|
Keyboard shortcut.
TYPE:
|
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:
|
text
|
Override text (some predefined items accept this).
TYPE:
|
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:
|
text
|
Display text for the submenu entry.
TYPE:
|
enabled
|
Whether the submenu is interactive.
TYPE:
|
items
|
Child menu item configurations.
TYPE:
|
pywry.types.MenuConfig
dataclass
¶
Top-level menu configuration.
| PARAMETER | DESCRIPTION |
|---|---|
id
|
Menu identifier.
TYPE:
|
items
|
Menu item configurations.
TYPE:
|
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:
|
tooltip
|
Hover tooltip text.
TYPE:
|
title
|
Tray icon title (macOS menu bar text).
TYPE:
|
icon
|
RGBA icon bytes.
TYPE:
|
icon_width
|
Icon width in pixels.
TYPE:
|
icon_height
|
Icon height in pixels.
TYPE:
|
menu
|
Menu to attach to the tray icon.
TYPE:
|
menu_on_left_click
|
Whether left click shows the menu.
TYPE:
|
on_click
|
Handler for single-click events.
TYPE:
|
on_double_click
|
Handler for double-click events.
TYPE:
|
on_right_click
|
Handler for right-click events.
TYPE:
|