pywry.tray_proxy¶
IPC-backed system tray icon management.
TrayProxy sends commands to the pytauri subprocess to create and control
system tray icons, menus, and events. See the System Tray guide
for usage patterns and examples.
pywry.tray_proxy.TrayProxy
¶
Proxy for a system tray icon living in the pytauri subprocess.
Instances are not created directly — use the :meth:create class
method which sends the tray_create IPC command and returns a proxy.
| PARAMETER | DESCRIPTION |
|---|---|
tray_id
|
The tray icon identifier.
TYPE:
|
Attributes¶
Functions¶
create
classmethod
¶
create(tray_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) -> TrayProxy
Create a system tray icon in the subprocess.
| PARAMETER | DESCRIPTION |
|---|---|
tray_id
|
Unique tray icon identifier.
TYPE:
|
tooltip
|
Hover tooltip text.
TYPE:
|
title
|
Tray 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.
TYPE:
|
menu_on_left_click
|
Whether left click opens the menu.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
TrayProxy
|
Proxy connected to the created tray icon. |
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
If the subprocess cannot be started or the tray creation fails. |
from_config
classmethod
¶
from_config(config: TrayIconConfig) -> TrayProxy
Create a tray icon from a :class:TrayIconConfig.
Automatically registers any handlers declared on the config:
config.on_click→tray:clickconfig.on_double_click→tray:double-clickconfig.on_right_click→tray:right-click- Item handlers from
config.menu→tray:menu-click
| PARAMETER | DESCRIPTION |
|---|---|
config
|
Complete tray icon configuration.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
TrayProxy
|
|
set_icon
¶
Update the tray icon image.
| PARAMETER | DESCRIPTION |
|---|---|
icon
|
RGBA icon bytes.
TYPE:
|
width
|
Icon width.
TYPE:
|
height
|
Icon height.
TYPE:
|
set_menu
¶
set_menu(menu: MenuConfig) -> None
Attach or replace the tray menu.
Handlers declared on items in menu are registered
automatically — the same as when creating via
:meth:from_config. Previous menu handlers are replaced.
| PARAMETER | DESCRIPTION |
|---|---|
menu
|
New menu configuration.
TYPE:
|
set_menu_on_left_click
¶
Control whether left click shows the tray menu.
on
¶
Register a callback for tray events.
Event types use the tray: namespace:
tray:click— single clicktray:double-click— double clicktray:right-click— right click (convenience alias)tray:enter— cursor enters tray icon areatray:leave— cursor leaves tray icon areatray:move— cursor moves over tray icon area
| PARAMETER | DESCRIPTION |
|---|---|
event_type
|
Event type string (e.g.
TYPE:
|
callback
|
Handler function.
TYPE:
|
remove_all
classmethod
¶
Remove every tracked tray icon.
Called by :meth:PyWry.destroy to guarantee cleanup regardless
of whether trays were created via app.create_tray() or
TrayProxy.from_config().
_register_menu_handlers
¶
_register_menu_handlers(menu: MenuConfig) -> None
Collect handlers from menu and (re-)register the dispatcher.