pyqt_reactive.protocols.window_factory
Window factory protocol and ABC for creating scope-aware windows.
Applications should subclass WindowFactoryABC and register it with register_window_factory() to provide scope-specific window creation.
Example
- class MyAppWindowFactory(WindowFactoryABC):
- def create_window_for_scope(self, scope_id: str, object_state=None):
- if scope_id == “”:
return self._create_global_config_window()
- elif “::” in scope_id:
return self._create_step_editor_window(scope_id, object_state)
- else:
return self._create_config_window(scope_id)
register_window_factory(MyAppWindowFactory())
Functions
Get the registered window factory. |
|
|
Register a global window factory. |
Classes
Abstract base class for window factories. |
|
|
Protocol for creating windows for a given scope. |
- class pyqt_reactive.protocols.window_factory.WindowFactoryProtocol(*args, **kwargs)[source]
Protocol for creating windows for a given scope.
Use this for duck-typed checking. For implementation, prefer WindowFactoryABC.
- create_window_for_scope(scope_id: str, object_state: Any | None = None) QWidget | None[source]
Create and show a window for the given scope id.
- __init__(*args, **kwargs)
- class pyqt_reactive.protocols.window_factory.WindowFactoryABC[source]
Abstract base class for window factories.
Subclass this to implement application-specific window creation logic. The factory is responsible for: - Parsing scope_id format to determine window type - Creating the appropriate window class - Showing and activating the window
- abstractmethod create_window_for_scope(scope_id: str, object_state: Any | None = None) QWidget | None[source]
Create and show a window for the given scope_id.
- Parameters:
scope_id – Scope identifier. Format is application-specific, e.g.: - “” (empty string): Global config - “/path/to/item”: Item-level config - “/path/to/item::sub”: Nested scope
object_state – Optional ObjectState for time-travel restore
- Returns:
The created window, or None if creation failed/skipped
- pyqt_reactive.protocols.window_factory.register_window_factory(factory: WindowFactoryProtocol) None[source]
Register a global window factory.
- Parameters:
factory – Factory instance implementing WindowFactoryProtocol or WindowFactoryABC
- pyqt_reactive.protocols.window_factory.get_window_factory() WindowFactoryProtocol | None[source]
Get the registered window factory.