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_view builds; 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

run()[source]
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_model wires 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
connect(*, view, signals)[source]
Parameters:
  • view (ViewT)

  • signals (Sequence[Signal[Unpack[Ts]]])

Return type:

_ConnectModelDecorator[ViewT, MainViewT, ModelT, Unpack[Ts]]

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 renders instead.

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, MapView shows 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.

Parameters:

view_type (type[View])

Return type:

bool

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 one BACKEND_VARIABLE names, else on default_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. With build_model, the app has a model, wired to its main view by setup_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