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
4mod image;
5mod interpreter;
6use interpreter::{ComponentCompiler, PyDiagnostic, PyDiagnosticLevel, PyValueType};
7mod brush;
8mod errors;
9mod models;
10mod timer;
11mod value;
12
13#[pyfunction]
14fn run_event_loop() -> Result<(), errors::PyPlatformError> {
15 slint_interpreter::run_event_loop().map_err(|e: PlatformError| e.into())
16}
17
18#[pyfunction]
19fn quit_event_loop() -> Result<(), errors::PyEventLoopError> {
20 slint_interpreter::quit_event_loop().map_err(|e: EventLoopError| e.into())
21}
22
23use pyo3::prelude::*;
24
25#[pymodule]
26fn 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