pywry.menu_proxy¶
IPC-backed native menu management.
MenuProxy sends commands to the pytauri subprocess to create, mutate, and
attach native OS menus. See the Native Menus guide for
usage patterns and examples.
pywry.menu_proxy.MenuProxy
¶
Proxy for a native menu living in the pytauri subprocess.
Stores the {item_id: handler} map extracted from items at creation
time. Call :meth:register_handlers with a window label to wire
everything up before the window is shown.
| PARAMETER | DESCRIPTION |
|---|---|
menu_id
|
The menu identifier (matches the subprocess-side
TYPE:
|
handlers
|
Mapping of
TYPE:
|
Attributes¶
Functions¶
create
classmethod
¶
create(menu_id: str, items: list[MenuItemKindConfig] | None = None) -> MenuProxy
Create a native menu in the subprocess.
Handlers are automatically extracted from every item that has one.
| PARAMETER | DESCRIPTION |
|---|---|
menu_id
|
Unique menu identifier.
TYPE:
|
items
|
Initial menu items. Each item must implement
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
MenuProxy
|
Proxy connected to the created menu. |
from_config
classmethod
¶
from_config(config: MenuConfig) -> MenuProxy
Create a native menu from a :class:MenuConfig.
Handlers are extracted from the config's item tree automatically.
| PARAMETER | DESCRIPTION |
|---|---|
config
|
Complete menu configuration.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
MenuProxy
|
|
register_handlers
¶
Register all item handlers for a window label.
Installs a single menu:click callback on label that dispatches
to the correct item handler based on data["item_id"].
Safe to call multiple times — duplicate registrations are ignored.
| PARAMETER | DESCRIPTION |
|---|---|
label
|
The window label to register handlers on.
TYPE:
|
insert
¶
Insert an item at a specific position.
set_checked
¶
Set the checked state of a check menu item.
set_accelerator
¶
Set or clear the keyboard accelerator for a menu item.
set_icon
¶
Set the icon for an icon menu item.
set_as_window_menu
¶
Attach this menu to a specific window.
| PARAMETER | DESCRIPTION |
|---|---|
window_label
|
The target window's label.
TYPE:
|
popup
¶
Show this menu as a context menu.
| PARAMETER | DESCRIPTION |
|---|---|
window_label
|
The window to show the popup on.
TYPE:
|
x
|
X coordinate (logical pixels).
TYPE:
|
y
|
Y coordinate (logical pixels).
TYPE:
|