mirror of
https://github.com/slint-ui/slint.git
synced 2025-07-16 01:25:27 +00:00
Python: Initial support for implementing models in Python
This provides a Model base class in Python and sub-classes of that can be set as data models in slint. The ListModel is provided as basic sub-class operating on a list() and allowing mutation and notifying the view on the Slint side. Similarly, an array declared in Slint is exposed as an object to Python that looks like a Model. Both support the sequence protocol. Fixes #4135
This commit is contained in:
parent
82d784a4d4
commit
2f313f84ec
6 changed files with 393 additions and 1 deletions
|
@ -6,6 +6,7 @@ mod interpreter;
|
|||
use interpreter::{ComponentCompiler, PyDiagnostic, PyDiagnosticLevel, PyValueType};
|
||||
mod brush;
|
||||
mod errors;
|
||||
mod models;
|
||||
mod timer;
|
||||
mod value;
|
||||
|
||||
|
@ -38,6 +39,7 @@ fn slint(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
|
|||
m.add_class::<timer::PyTimer>()?;
|
||||
m.add_class::<brush::PyColor>()?;
|
||||
m.add_class::<brush::PyBrush>()?;
|
||||
m.add_class::<models::PyModelBase>()?;
|
||||
m.add_function(wrap_pyfunction!(run_event_loop, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(quit_event_loop, m)?)?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue