composeui.core.model¶
The model: the app’s data beside its views, saved and opened with them in a study.
- exception composeui.core.model.InvalidStateError[source]¶
Bases:
ValueErrorA saved study that can’t be opened; the views and the model are left unchanged.
- class composeui.core.model.Model[source]¶
Bases:
objectThe app’s data beside its views, given to the callbacks asking for
model.A model with data of its own names its file in
data_name. The study is then saved as an archive of the views’ state and that file (seecomposeui.core.study). New, Open and Save reach the model through the methods below. Without adata_name, Save and Open don’t callsave_dataandopen_data, and the study stays the views’ JSON.- data_name: ClassVar[str | None] = None¶
the model’s file inside a saved study; None for a model with nothing to save
- property signals: list[Signal[Unpack[tuple[Any, ...]]]]¶
Get the model’s signals: its attributes that are one, unless a subclass adds some.
The app gives them the main view and the model, as it does the views’ own signals. A callback that asks for
main_viewormodelby name gets it.
- save_data(path)[source]¶
Write the data into the file
path.- Parameters:
path (Path)
- Return type:
None
- open_data(path)[source]¶
Replace the data with the file
path’s.Raises
InvalidStateError, leaving the data unchanged, for a file that doesn’t fit.- Parameters:
path (Path)
- Return type:
None