1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
2 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial |
3 | |
4 | mod image; |
5 | mod interpreter; |
6 | use interpreter::{ComponentCompiler, PyDiagnostic, PyDiagnosticLevel, PyValueType}; |
7 | mod brush; |
8 | mod errors; |
9 | mod models; |
10 | mod timer; |
11 | mod value; |
12 | |
13 | #[pyfunction ] |
14 | fn run_event_loop() -> Result<(), errors::PyPlatformError> { |
15 | slint_interpreter::run_event_loop().map_err(|e: PlatformError| e.into()) |
16 | } |
17 | |
18 | #[pyfunction ] |
19 | fn quit_event_loop() -> Result<(), errors::PyEventLoopError> { |
20 | slint_interpreter::quit_event_loop().map_err(|e: EventLoopError| e.into()) |
21 | } |
22 | |
23 | use pyo3::prelude::*; |
24 | |
25 | #[pymodule ] |
26 | fn slint(_py: Python<'_>, m: &PyModule) -> PyResult<()> { |
27 | i_slint_backend_selector::with_platform(|_b| { |
28 | // Nothing to do, just make sure a backend was created |
29 | Ok(()) |
30 | }) |
31 | .map_err(|e: PlatformError| errors::PyPlatformError(e))?; |
32 | |
33 | m.add_class::<ComponentCompiler>()?; |
34 | m.add_class::<image::PyImage>()?; |
35 | m.add_class::<PyValueType>()?; |
36 | m.add_class::<PyDiagnosticLevel>()?; |
37 | m.add_class::<PyDiagnostic>()?; |
38 | m.add_class::<timer::PyTimerMode>()?; |
39 | m.add_class::<timer::PyTimer>()?; |
40 | m.add_class::<brush::PyColor>()?; |
41 | m.add_class::<brush::PyBrush>()?; |
42 | m.add_class::<models::PyModelBase>()?; |
43 | m.add_function(fun:wrap_pyfunction!(run_event_loop, m)?)?; |
44 | m.add_function(fun:wrap_pyfunction!(quit_event_loop, m)?)?; |
45 | |
46 | Ok(()) |
47 | } |
48 | |