spacr.qt.bridge
===============

.. py:module:: spacr.qt.bridge

.. autoapi-nested-parse::

   Background execution + progress bridge between the Qt UI and the pipeline
   functions in spacr.core / spacr.deep_spacr / spacr.submodules / etc.

   Runs each pipeline call in a QThread so the UI stays responsive. The
   worker installs stdout/stderr shims that emit `line_ready(str)` on every
   print, so the caller can pipe them into a QPlainTextEdit console.







Module Contents
---------------

.. py:class:: PipelineWorker(fn: Callable[Ellipsis, Any], settings: Dict[str, Any])

   Bases: :py:obj:`PySide6.QtCore.QObject`


   Runs one pipeline function in its own thread.

   Signals:
       line_ready(str)  — a chunk of stdout/stderr text
       finished(bool)   — True if the function returned without an
                           unhandled exception
       error(str)       — traceback string on failure
       figure_ready(object)
                        — a matplotlib Figure that the pipeline
                           asked to show(); emitted from the worker
                           thread so the UI slot can attach it.


   .. py:attribute:: line_ready


   .. py:attribute:: finished


   .. py:attribute:: error


   .. py:attribute:: figure_ready


   .. py:method:: run() -> None

      Invoked by QThread.started; runs the pipeline function to completion.



.. py:function:: resolve_pipeline_entry(app_key: str) -> Callable[[Dict[str, Any]], Any] | None

   Return the pipeline function that runs a given app, or None if the
   app is interactive-only (annotate / make_masks) or unknown.


.. py:function:: make_thread(fn: Callable[[Dict[str, Any]], Any], settings: Dict[str, Any]) -> tuple[PySide6.QtCore.QThread, PipelineWorker]

   Return (thread, worker) — caller connects worker signals and calls
   thread.start().


