composeui.core.application¶
The app: it builds the main view, wires its signals and runs it on a backend (run).
- class composeui.core.application.Application[source]¶
Bases:
Generic[MainViewT]An app showing the main view
build_main_viewbuilds; each backend has its own.The app builds its main view itself, so every backend takes the same arguments: a web app builds one per browser session.
- backend: ClassVar[RendererType | None] = None¶
the backend that shows the app, given by each backend’s app (
current_backend)
- __init__(*, build_main_view)[source]¶
- Parameters:
build_main_view (Callable[[], MainViewT])
- Return type:
None
- property main_view: MainViewT¶
- connect(*, view, signals)[source]¶
- Parameters:
view (ViewT)
signals (Sequence[Signal[Unpack[Ts]]])
- Return type:
_ConnectDecorator[ViewT, MainViewT, Unpack[Ts]]
- render(renderer_type)[source]¶
- Parameters:
renderer_type (RendererType)
- Return type:
None
- class composeui.core.application.ModelApplication[source]¶
Bases:
Application[MainViewT],Generic[MainViewT,ModelT]An app with a model beside its main view, given to the callbacks asking for
model.setup_modelwires them once both are built, e.g. to refresh views when the model changes.- __init__(*, build_main_view, build_model, setup_model=None)[source]¶
- Parameters:
build_main_view (Callable[[], MainViewT])
build_model (Callable[[], ModelT])
setup_model (Callable[[MainViewT, ModelT], None] | None)
- Return type:
None
- property model: ModelT¶
- composeui.core.application.current_backend()[source]¶
Get the backend of the app running, e.g.
RendererType.QT; None before an app is built.It is set before the app builds its main view, so the views can read it as they are built. To tell whether the backend shows a kind of view, use
rendersinstead.- Return type:
RendererType | None
- composeui.core.application.renders(view_type)[source]¶
Tell whether the backend of the app running shows views of
view_type.For example,
MapViewshows on Qt and the web, but not on Textual, where an app can show a table of the points instead. False before an app is built.
- composeui.core.application.run(build_main_view, *, build_model=None, setup_model=None, default_backend=RendererType.WEB)[source]¶
Run the app on the backend the command line names, e.g.
--backend qt.Without
--backend, on the oneBACKEND_VARIABLEnames, else ondefault_backend. The rest of the command line goes to the backend’s app (-f,--language,--port,--help…). Only that backend is imported, so the others’ extras needn’t be installed; without its own, it stops and names the extra. Withbuild_model, the app has a model, wired to its main view bysetup_model: once, or per session on the web.- Parameters:
build_main_view (Callable[[], MainViewT])
build_model (Callable[[], ModelT] | None)
setup_model (Callable[[MainViewT, ModelT], None] | None)
default_backend (RendererType)
- Return type:
None