wolfhece._menu_companion_template ================================= .. py:module:: wolfhece._menu_companion_template .. autoapi-nested-parse:: Template module for menu-based companions. Purpose ------- This file is a starter kit to create new companions following the same structure used in existing managers such as: - _qdfidf_manager.py - _simtools2d_manager.py - _weir_manager.py - _particlesystem_manager.py How to use ---------- 1) Copy this file and rename class/module to your feature. 2) Instantiate it in WolfMapViewer.__init__. 3) Call menu_build() from the same place where other companion menus are built. 4) Replace example handlers with your business logic. Integration sketch in PyDraw.py ------------------------------- from ._my_feature_manager import MyFeatureManager ... self._my_feature_mgr = MyFeatureManager(self) ... self._my_feature_mgr.menu_build() Module Contents --------------- .. py:class:: MenuCompanionTemplate(viewer: wolfhece.PyDraw.WolfMapViewer) Reusable template for a menu-based companion manager. .. py:attribute:: _viewer .. py:attribute:: _menu :type: wx.Menu | None :value: None .. py:attribute:: _submenu_tools :type: wx.Menu | None :value: None .. py:method:: menu_build() -> None Build the top-level menu once and bind all handlers. .. py:method:: _require_active_array() -> bool Return True if an active array exists, else log and abort. .. py:method:: _show_error(message: str) -> None Show a standard error dialog. .. py:method:: _on_check_context(event: wx.MenuEvent) -> None Minimal action showing guard usage. .. py:method:: _on_pick(event: wx.MenuEvent) -> None Interactive action example (ActionKind driven). .. py:method:: _on_run_tool(event: wx.MenuEvent) -> None Long action example with progress dialog and final refresh. .. py:method:: _on_export(event: wx.MenuEvent) -> None Export-like action with explicit try/except error flow.