pyqt_reactive.services.scope_window_factory
Generic scope-based window factory for pyqt-reactive.
Provides a registry-based system where applications register handlers for different scope patterns. The factory dispatches to the appropriate handler based on scope_id patterns.
Example
# Register a handler for a scope pattern ScopeWindowRegistry.register_handler(
pattern=r”^$”, # Empty scope (global config) handler=create_global_config_window
)
# Create window via factory window = WindowFactory.create_window_for_scope(scope_id)
Classes
|
Typed request to materialize one ObjectState-backed UI scope. |
Resolved WindowManager target for one requested ObjectState scope. |
|
Registry mapping scope patterns to window creation handlers. |
|
|
One registered scope matcher and its window creation behavior. |
Generic window factory that dispatches to registered handlers. |
- class pyqt_reactive.services.scope_window_factory.ScopeWindowCreationRequest(scope_id: str, object_state: ObjectState | None = None)[source]
Typed request to materialize one ObjectState-backed UI scope.
Resolved WindowManager target for one requested ObjectState scope.
- class pyqt_reactive.services.scope_window_factory.ScopeWindowRoute(pattern: str, handler: ~collections.abc.Callable[[~pyqt_reactive.services.scope_window_factory.ScopeWindowCreationRequest], ~PyQt6.QtWidgets.QWidget | None] | None = None, window_scope_resolver: ~collections.abc.Callable[[str], str] = <function _identity_scope>, field_path_resolver: ~collections.abc.Callable[[str, str | None], str | None] = <function _identity_field_path>, item_id_resolver: ~collections.abc.Callable[[str, str | None], str | None] = <function _identity_item_id>)[source]
One registered scope matcher and its window creation behavior.
- handler: Callable[[ScopeWindowCreationRequest], QWidget | None] | None
- create_window(request: ScopeWindowCreationRequest) QWidget | None[source]
- __init__(pattern: str, handler: ~collections.abc.Callable[[~pyqt_reactive.services.scope_window_factory.ScopeWindowCreationRequest], ~PyQt6.QtWidgets.QWidget | None] | None = None, window_scope_resolver: ~collections.abc.Callable[[str], str] = <function _identity_scope>, field_path_resolver: ~collections.abc.Callable[[str, str | None], str | None] = <function _identity_field_path>, item_id_resolver: ~collections.abc.Callable[[str, str | None], str | None] = <function _identity_item_id>) None
- class pyqt_reactive.services.scope_window_factory.ScopeWindowRegistry[source]
Registry mapping scope patterns to window creation handlers.
Handlers are matched in registration order (first match wins).
- classmethod register_handler(pattern: str, handler: ~collections.abc.Callable[[~pyqt_reactive.services.scope_window_factory.ScopeWindowCreationRequest], ~PyQt6.QtWidgets.QWidget | None] | None = None, *, window_scope_resolver: ~collections.abc.Callable[[str], str] = <function _identity_scope>, field_path_resolver: ~collections.abc.Callable[[str, str | None], str | None] = <function _identity_field_path>, item_id_resolver: ~collections.abc.Callable[[str, str | None], str | None] = <function _identity_item_id>) None[source]
Register a handler for scopes matching the given regex pattern.
- Parameters:
pattern – Regex pattern to match against scope_id
handler – Callable(ScopeWindowCreationRequest) -> QWidget | None
- classmethod register_route(route: ScopeWindowRoute) None[source]
Register one nominal scope-window route.
- classmethod find_handler(scope_id: str) ScopeWindowRoute | None[source]
Find the first route matching the scope_id.
- class pyqt_reactive.services.scope_window_factory.WindowFactory[source]
Generic window factory that dispatches to registered handlers.
Applications register handlers for their specific scope patterns, then use this factory to create windows without hardcoding domain logic.
- classmethod create_window_for_scope(scope_id: str, object_state: ObjectState | None = None) QWidget | None[source]
Create a window for the given scope_id.
Dispatches to the first registered handler that matches the scope_id.
- Parameters:
scope_id – Unique identifier for the scope/object
object_state – Optional ObjectState instance (for time-travel scenarios)
- Returns:
The created window, or None if no handler matched