Source code for ewoksxas.canvas

"""Canvas launcher for ewoksxas.

Thin wrapper around ``ewoksorange.gui.canvas.main.main`` that raises the toolbar
priority of the third-party ``orangecontrib.spectroscopy`` category before widget
discovery runs. We cannot edit that package's source, so we patch its category
module global here. Our own "X-Ray Spectroscopy" category sets ``PRIORITY``
statically in ``orangecontrib.ewoksxas.widgets``; only the external Spectroscopy
category needs this runtime patch.

Relies on ewoksorange's ``main`` force-appending ``--force-discovery`` (which
invalidates any cached registry), so the patched PRIORITY is read on a fresh pass.
"""

from ewoksorange.gui.canvas.main import main as _ewoks_main

# Lower sorts nearer the top; kept distinct from the ewoksxas category value
# (-20) so ordering is deterministic (X-Ray Spectroscopy above Spectroscopy).
_SPECTROSCOPY_PRIORITY = -10


def _boost_spectroscopy_category() -> None:
    try:
        import orangecontrib.spectroscopy.widgets as _spectroscopy_widgets  # noqa: PLC0415
    except ImportError:
        # orange-spectroscopy is a hard dependency, but never block the canvas
        # from launching if its widget package is unavailable.
        return
    _spectroscopy_widgets.PRIORITY = _SPECTROSCOPY_PRIORITY


[docs] def main(argv=None): _boost_spectroscopy_category() return _ewoks_main(argv)
if __name__ == "__main__": main()