composeui.core.renderer¶
The base classes of the renderers, which show a view with a widget of a toolkit.
- class composeui.core.renderer.MainRenderer[source]¶
Bases:
Renderer[TView,TObject]A root-window renderer: the app-level operations a
MainViewrelies on.Lets
MainViewtalk to whichever backend rendered it throughisinstancechecks against this class alone, without importing any backend package.- draws_on_main_thread: ClassVar[bool] = True¶
whether the app’s window is drawn on the main thread, which long work there freezes (Qt, Textual): a view then runs it in a job. The web’s requests have threads of their own
- exception composeui.core.renderer.MissingRefreshAttributeFunctionError[source]¶
Bases:
ExceptionA changed field of a view that its renderer has no handler for.
- exception composeui.core.renderer.NoRenderedObjectError[source]¶
Bases:
ExceptionA renderer used before
Renderer.renderbuilt its widget.
- class composeui.core.renderer.Renderer[source]¶
Bases:
ABC,Generic[TView,TObject]The base of a backend’s renderers: one shows a view with a widget of its toolkit.
renderbuilds the widget.refresh_attributeshows a new value of a field of the view, with the handler of_refresh_dispatcherfor that field. The renderer sets the view’s fields from the widget’s signals, insidestop_refresh, so the view doesn’t show them back.- call_on_main_thread(callback)[source]¶
Invoke
callbackon the thread that owns the GUI event loop.Default: no real thread affinity to worry about outside a GUI toolkit, so just call it directly. Toolkit-bound renderers (e.g. Qt, whose widgets can only be touched from the thread that created them) must override this to marshal the call onto their main thread instead.
- Parameters:
callback (Callable[[], None])
- Return type:
None
- refresh()[source]¶
Show every field of the view that has a handler in
_refresh_dispatcher.- Return type:
None
- refresh_attribute(attr_name, value)[source]¶
Show
value, the new value of the view’s fieldattr_name.Raises
MissingRefreshAttributeFunctionErrorwhen no handler shows the field.
- class composeui.core.renderer.RendererContainer[source]¶
Bases:
Generic[TView]The renderers of a view shown by several widgets, e.g. a form row’s label and field.
- call_on_main_thread(callback)[source]¶
Invoke
callbackon the thread that owns the GUI event loop.Delegates to one of its renderers: they all share the same toolkit and thread.
- Parameters:
callback (Callable[[], None])
- Return type:
None