Source code for wolfhece._builtin_plugins._template.companion

"""
Template companion plugin.

Replace every occurrence of ``MyPlugin`` / ``my_plugin`` with your own name,
then implement the methods below.

Rename this directory to match the ``name`` field in ``plugin.toml``
(removing the leading ``_`` so it is auto-discovered).
"""
from wolfhece._menu_companion_abc import AbstractCompanion, ActionItem
from wolfhece._viewer_plugin_handlers import MouseContext, KeyboardSnapshot

# wx key codes — avoid importing wx at module level
[docs] _WXK_ESCAPE = 27
[docs] class MyPluginCompanion(AbstractCompanion): """Minimal template — replace with your implementation."""
[docs] def menu_build(self) -> None: """Add a top-level menu entry. Remove if no menu is needed.""" self._build_menu('My Plugin', [ ActionItem('Run…', self._on_run, 'Start the interactive action'), ]) self._register_action( self._action_id('run'), rdown=self._rdown, key=self._key, paint=self._paint, )
[docs] def start(self) -> None: """Called when the companion is activated programmatically.""" self._start_action( self._action_id('run'), 'Right-click to interact — Esc to stop', )
# -- handlers ------------------------------------------------------------
[docs] def _on_run(self, event) -> None: self.start()
[docs] def _rdown(self, viewer, ctx: MouseContext) -> None: # TODO: implement your right-click handler self._force_redraw()
[docs] def _key(self, viewer, kb: KeyboardSnapshot) -> bool: if kb.key_code == _WXK_ESCAPE: self.stop() return True return False
[docs] def _paint(self, viewer) -> None: # TODO: draw your OpenGL overlay pass