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

ScopeWindowCreationRequest(scope_id[, ...])

Typed request to materialize one ObjectState-backed UI scope.

ScopeWindowNavigationTarget(...)

Resolved WindowManager target for one requested ObjectState scope.

ScopeWindowRegistry()

Registry mapping scope patterns to window creation handlers.

ScopeWindowRoute(pattern, handler, ...)

One registered scope matcher and its window creation behavior.

WindowFactory()

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.

scope_id: str
object_state: ObjectState | None
__init__(scope_id: str, object_state: ObjectState | None = None) None
class pyqt_reactive.services.scope_window_factory.ScopeWindowNavigationTarget(requested_scope_id: str, window_scope_id: str, item_id: str | None, field_path: str | None)[source]

Resolved WindowManager target for one requested ObjectState scope.

requested_scope_id: str
window_scope_id: str
item_id: str | None
field_path: str | None
__init__(requested_scope_id: str, window_scope_id: str, item_id: str | None, field_path: str | None) None
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.

pattern: str
handler: Callable[[ScopeWindowCreationRequest], QWidget | None] | None
window_scope_resolver: Callable[[str], str]
field_path_resolver: Callable[[str, str | None], str | None]
item_id_resolver: Callable[[str, str | None], str | None]
matches(scope_id: str) bool[source]
create_window(request: ScopeWindowCreationRequest) QWidget | None[source]
navigation_target(scope_id: str, *, item_id: str | None = None, field_path: str | None = None) ScopeWindowNavigationTarget[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 unregister_handler(pattern: str) None[source]

Remove a handler by pattern.

classmethod clear() None[source]

Clear all registered handlers.

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