Backends¶
Each backend has an application class, and a model application class for an app with a
model. composeui.core.application.run starts the classes of the backend that the
command line selects.
Qt¶
The application classes of the Qt backend.
- class composeui.qtcore.qtapplication.QtApplication[source]¶
Bases:
Application[MainViewT]The Qt app: it shows the main view in a window.
- backend: ClassVar[RendererType | None] = ('composeui.qtcore.qtrenderer', 'composeui.qtcore.qtapplication', 'pyside6', ('PySide6', 'pyqtgraph', 'qtpy'))¶
the backend that shows the app, given by each backend’s app (
current_backend)
- class composeui.qtcore.qtapplication.QtModelApplication[source]¶
Bases:
ModelApplication[MainViewT,ModelT]The Qt app with a model, which it closes once the window is closed.
- backend: ClassVar[RendererType | None] = ('composeui.qtcore.qtrenderer', 'composeui.qtcore.qtapplication', 'pyside6', ('PySide6', 'pyqtgraph', 'qtpy'))¶
the backend that shows the app, given by each backend’s app (
current_backend)
- composeui.qtcore.qtapplication.APPLICATION¶
the backend’s applications, for
composeui.core.application.run
- composeui.qtcore.qtapplication.MODEL_APPLICATION¶
alias of
QtModelApplication
Textual¶
The application classes of the Textual backend.
- class composeui.textualcore.textualapplication.TextualApplication[source]¶
Bases:
Application[MainViewT]The Textual app: it shows the main view in the terminal.
- backend: ClassVar[RendererType | None] = ('composeui.textualcore.textualrenderer', 'composeui.textualcore.textualapplication', 'tui', ('textual', 'textual_fspicker', 'textual_plotext'))¶
the backend that shows the app, given by each backend’s app (
current_backend)
- class composeui.textualcore.textualapplication.TextualModelApplication[source]¶
Bases:
ModelApplication[MainViewT,ModelT]The Textual app with a model, which it closes once the app exits.
- backend: ClassVar[RendererType | None] = ('composeui.textualcore.textualrenderer', 'composeui.textualcore.textualapplication', 'tui', ('textual', 'textual_fspicker', 'textual_plotext'))¶
the backend that shows the app, given by each backend’s app (
current_backend)
- composeui.textualcore.textualapplication.APPLICATION¶
the backend’s applications, for
composeui.core.application.run
- composeui.textualcore.textualapplication.MODEL_APPLICATION¶
alias of
TextualModelApplication
Web¶
The application classes of the web backend.
- composeui.webcore.webapplication.create_starlette_app(sessions, *, secret_key=None, reloading=False)[source]¶
Create the Starlette app serving one main view per browser session.
secret_keysigns the session cookie, a new one by default. A--reloadserver’s process (reloading) saves the sessions as it stops (SessionStore.save_all), and its pages reload once another process serves (reload_poll).
- composeui.webcore.webapplication.create_reloaded_starlette_app()[source]¶
Build the app of the program named by
_RELOAD_ENTRY_VARIABLE:--reload’s factory.uvicorn’s reloader serves from a new process, started again after every change. That process doesn’t run the program that started the server. So this function runs the program again, with the command line the process inherited (
-f,--debug, …). It keeps the app whoserunthe program reaches, instead of serving it. So an app built inline, connected or configured by the program’smain()comes back just as it was.- Return type:
Starlette
- class composeui.webcore.webapplication.WebApplication[source]¶
Bases:
Application[MainViewT]The web app: it serves the main view over HTTP, one
MainViewper browser session.main_viewis only a template, for the command line (e.g.-f’s extension check). Every session gets its own instance frombuild_main_view. Soconnect(view=app.main_view..., ...)doesn’t wire the template. It records where the view and the signals sit in the template. Every new session then connects the callback to its own view and signals, with its ownviewandmain_view. Connect before serving: a session already open keeps the connections it was built with.- backend: ClassVar[RendererType | None] = ('composeui.webcore.webrenderer', 'composeui.webcore.webapplication', 'web', ('itsdangerous', 'markdown_it', 'markupsafe', 'python_multipart', 'starlette', 'uvicorn'))¶
the backend that shows the app, given by each backend’s app (
current_backend)
- max_sessions: ClassVar[int] = 1000¶
most sessions live at once: past it, a new browser gets 503 until one is dropped (each holds a main view, and maybe a model, in memory)
- __init__(*, build_main_view)[source]¶
- Parameters:
build_main_view (Callable[[], MainViewT])
- Return type:
None
- connect(*, view, signals)[source]¶
- Parameters:
view (ViewT)
signals (Sequence[Signal[Unpack[Ts]]])
- Return type:
_ConnectDecorator[ViewT, MainViewT, Unpack[Ts]]
- setup_session(main_view)[source]¶
Wire a new session’s main view; override to connect app-level behavior.
- Parameters:
main_view (MainViewT)
- Return type:
None
- create_starlette_app(*, saved_sessions=None, secret_key=None)[source]¶
Create the Starlette app, building a fresh main view for each new session.
A page whose route takes one of the backend’s addresses stops it here, before serving, rather than failing every request. A
--reloadserver’s process getssaved_sessions, the directory where its processes leave their sessions to the next, andsecret_key, which they all sign the sessions’ cookies with.
- class composeui.webcore.webapplication.WebModelApplication[source]¶
Bases:
WebApplication[MainViewT],Generic[MainViewT,ModelT]A
WebApplicationwhose every session also gets its own model frombuild_model.Each session has its own model, as it has its own main view. A browser only ever sees the fragments its own requests return. So a model shared between sessions would leave every other browser showing stale views, and would need its own locking. Callbacks asking for
modelget their session’s model, whether a view’s own callbacks or those connected throughconnect.setup_modelwires each session’s model to its main view.- connect(*, view, signals)[source]¶
- Parameters:
view (ViewT)
signals (Sequence[Signal[Unpack[Ts]]])
- Return type:
_ConnectModelDecorator[ViewT, MainViewT, ModelT, Unpack[Ts]]
- setup_model(main_view, model)[source]¶
Wire a new session’s model to its main view: calls the
setup_modelgiven.Runs after
setup_session, e.g. to refresh views when aSqliteTablechanges.- Parameters:
main_view (MainViewT)
model (ModelT)
- Return type:
None
- composeui.webcore.webapplication.APPLICATION¶
the backend’s applications, for
composeui.core.application.run
- composeui.webcore.webapplication.MODEL_APPLICATION¶
alias of
WebModelApplication