Commit graph

181 commits

Author SHA1 Message Date
Simon Hausmann
2adb86de14 Python: Be conservative about attaching to the Python interpreter
We call Python::attach in a few places. When invoked from the Slint event loop, those should be fine. But there are some that may fail, for example during gc. Fall back to using try_attach and return default values instead of causing a panic.

Fixes #9984
2025-11-07 10:28:47 +00:00
GreyElaina
b15f6e85e8 refactor: restructure slint-compiler workflow 2025-10-30 10:13:32 +08:00
ogoffart
cad0a8ea83 Bump version number to 1.15.0 2025-10-24 14:28:17 +00:00
ogoffart
db7e383e33 Bump version number to 1.14.1 2025-10-22 13:17:31 +00:00
Olivier Goffart
804acf29d2 Fix licenses of .toml files 2025-10-22 04:56:10 +02:00
Simon Hausmann
dcd0945dfc
CI: Fix formatting 2025-10-14 08:52:48 +02:00
Simon Hausmann
f6dbe7749f Python: Add support for async callbacks with @slint.callback
Permit the use of `@slint.callback` on async functions. They will be run as tasks.
2025-10-14 07:25:33 +02:00
Simon Hausmann
197499e2a5
Fix formatting 2025-10-12 11:22:08 +02:00
Simon Hausmann
d743eda649 Python: Fix interaction with garbage collector when models are held in structs and properties
Models in Python have a strong reference to the Rust type, which have a strong reference back to the Python model. Therefore the __traverse__ and __clear__ protocol is implemented, to handle this cyclic reference.

The same protocol needs to be implemented for structs itself as well as basically all properties held by the interpreter.

Fixes #9706
2025-10-12 11:05:50 +02:00
Simon Hausmann
352eb54785 Python: Improve diagnostics around compile errors
Some checks are pending
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, 1.88) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, beta) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, stable) (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, 1.88) (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (windows-2022) (push) Blocked by required conditions
CI / cpp_test_driver (macos-14) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.88) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
CI / material-components (push) Blocked by required conditions
- Fix accidental swapping of line and column
- Use exception notes to feed the diagnostics into the exception in a
  more idiomatic manner

Fixes #5474
2025-10-10 11:57:05 +02:00
Simon Hausmann
7f4be51ad5 core: tidy up re-export of tr
Only export the one item we need, the Translator trait.
2025-09-29 12:50:22 +02:00
Simon Hausmann
2b68bc3cba Python: Document what PyGettextTranslator holds 2025-09-29 12:50:22 +02:00
Simon Hausmann
60d8897c8c core: re-export the tr crate when the tr feature is activated 2025-09-29 12:50:22 +02:00
Simon Hausmann
2bbe5e8786 Python: Added support for run-time translations from .slint files
Fixes #7956
2025-09-29 12:50:22 +02:00
Simon Hausmann
024cd63900 Python: Extend Timer docs with an example how to avoid garbage collection and thus stopped timer
Fixes #9429
2025-09-24 16:56:45 +02:00
Simon Hausmann
a159c15edd Python: Fix event loop terminating too early when the main coro finishes 2025-09-19 10:55:17 +02:00
Simon Hausmann
797f8f6469 Python: Improve exception handling for the coroutine passed to slint.run_event_loop()
Some checks are pending
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, beta) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, stable) (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / python_test (macos-14) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (windows-2022) (push) Blocked by required conditions
CI / cpp_test_driver (macos-13) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.85) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / docs (push) Blocked by required conditions
CI / wasm (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / wasm_demo (push) Blocked by required conditions
CI / tree-sitter (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
If an exception is thrown, propagate it. Otherwise it becomes difficult to debug...

cc #4137
2025-09-19 10:10:19 +02:00
Simon Hausmann
ea0e3c1372 Python: Initial support for asyncio
The API is minimal at this point: `slint.run_event_loop()` takes an
optional coroutine parameter, that's run. As the loop is run, an
asyncio event loop (as per asyncio.get_event_loop()) is active, which
maps socket operations to smol's Async adapter and polls them within the
Slint event loop.

cc #4137
2025-09-19 08:23:34 +02:00
Simon Hausmann
855cd0df14 Python: Add support for invoke_from_event_loop
Fixes #4203
2025-09-19 08:23:34 +02:00
Simon Hausmann
c404d60516 Python: Add support for sys.exit() from callbacks/timers/etc.
Instead of printing exceptions in callbacks to stderr, let's raise them as unraisable exceptions, but catch SystemExit and forward it through the event loop.

Fixes #9416
2025-09-15 13:42:46 +02:00
Simon Hausmann
66376bee18 Python: Upgrade to Pyo3 0.26 2025-09-15 12:21:28 +02:00
ogoffart
f2aa4899db Bump version number to 1.14.0 2025-09-11 14:01:14 +00:00
ogoffart
09e397f3ba Bump version number to 1.13.1 2025-09-08 09:43:17 +00:00
Simon Hausmann
c1831158fa Python: Add support for importing foreign image buffers
ChangeLog: [Python] Add support for creating slint.Image objects from arrays

Fixes #9014
2025-08-01 16:08:09 +02:00
Simon Hausmann
917c9a8c6a Python: Run mypy type checker on the slint compiler
Some checks failed
CI / cpp_test_driver (windows-2022) (push) Has been cancelled
CI / wasm_demo (push) Has been cancelled
CI / cpp_cmake (macos-14, 1.85) (push) Has been cancelled
CI / cpp_cmake (ubuntu-22.04, stable) (push) Has been cancelled
CI / cpp_cmake (windows-2022, nightly) (push) Has been cancelled
CI / cpp_package_test (push) Has been cancelled
CI / tree-sitter (push) Has been cancelled
CI / vsce_build_test (push) Has been cancelled
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, macos-14, stable) (push) Has been cancelled
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, beta) (push) Has been cancelled
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, stable) (push) Has been cancelled
CI / build_and_test (ubuntu-22.04, nightly) (push) Has been cancelled
CI / node_test (macos-14) (push) Has been cancelled
CI / node_test (ubuntu-22.04) (push) Has been cancelled
CI / node_test (windows-2022) (push) Has been cancelled
CI / python_test (macos-14) (push) Has been cancelled
CI / python_test (ubuntu-22.04) (push) Has been cancelled
CI / python_test (windows-2022) (push) Has been cancelled
CI / cpp_test_driver (macos-13) (push) Has been cancelled
CI / cpp_test_driver (ubuntu-22.04) (push) Has been cancelled
CI / android (push) Has been cancelled
CI / miri (push) Has been cancelled
CI / test-figma-inspector (push) Has been cancelled
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Has been cancelled
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Has been cancelled
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Has been cancelled
CI / mcu-embassy (push) Has been cancelled
CI / updater_test (0.3.0) (push) Has been cancelled
CI / fmt_test (push) Has been cancelled
CI / esp-idf-quick (push) Has been cancelled
2025-07-11 14:45:43 +02:00
Simon Hausmann
89c1497880 Python: Add missing project fields and fix version number for slint-compiler wrapper 2025-07-11 14:44:38 +02:00
Simon Hausmann
75052fb902 Python: Add wrapper for Slint Compiler
This permits invoking the Slint compiler conveniently via `uvx
slint-compiler` or `pipx slint-compiler`.

cc #4136
2025-07-11 14:07:56 +02:00
Simon Hausmann
82ae731fcb Python: Add support for enums
Support for enums is three-fold:

- Enums are dynamically created by invoking `enum.Enum("NameOfEnum",
  [("Variant1", "Variant1"), ("Variant2", "Variant2"), ...])` and the
  exposed in the module (next to structs).
- They're converted back to `Value::EnumerationValue(enum_name,
  enum_value)` by checking if a supplied value is an instance of
  `enum.Enum` and then querying the name and `__class__.name` fields.
- When coverting a `Value::EnumerationValue` to Python, the hard work
  begins: We now pass along a TypeCollection through all phases of the
  type conversion, which knows about the enums created earlier and tries
  to locate the correct type class and then variant.

Fixes #5828
2025-07-08 14:35:44 +02:00
Simon Hausmann
14e1ae3bc0 Python: Simplified IntoPyObject for SlintToPyValue
Avoid some clones as the conversion is consuming anyway.
2025-07-08 14:35:44 +02:00
Simon Hausmann
94018778c9 Python: Separate PyValue into PyToSlintValue and SlintToPyValue
For the latter, in the future, we need additional book-keeping.
2025-07-08 14:35:44 +02:00
ogoffart
9cc24ff284 Bump version number to 1.13.0 2025-06-26 13:30:43 +00:00
Simon Hausmann
4aae1aa3af Initial import of Briefcase plugin 2025-06-25 20:43:09 +02:00
Simon Hausmann
86befbe769 Python: Make space for additional python modules
Move Slint module into sub-directory under api/python
2025-06-25 20:43:09 +02:00
Simon Hausmann
acbe8b67ed Python: Use a beta suffix instead of alpha to reflect the beta nature of the port 2025-06-24 22:07:00 +02:00
ogoffart
92f9f0e85d Bump version number to 1.12.1 2025-06-16 13:32:39 +00:00
Simon Hausmann
3e26e4ef7a Python: Bump stub-gen version
Some checks are pending
CI / docs (push) Blocked by required conditions
CI / wasm (push) Blocked by required conditions
CI / wasm_demo (push) Blocked by required conditions
CI / tree-sitter (push) Blocked by required conditions
CI / files-changed (push) Waiting to run
CI / build_and_test (--exclude bevy-example, ubuntu-22.04, 1.82) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, --exclude bevy-example, windows-2022, 1.82) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, macos-14, stable) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, beta) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, stable) (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / python_test (macos-14) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (macos-13) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.82) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
2025-06-08 09:24:44 +00:00
Simon Hausmann
6e4e98af4e Python: Fix device architecture 2025-05-21 10:57:33 +02:00
Simon Hausmann
5046d02ae8 Python: Remove unnecessary maturin run-time dependency 2025-05-20 19:59:04 +02:00
Simon Hausmann
97a8ff66c1 Python: Fix ios wheel tags to match what warehouse accepts 2025-05-20 17:39:32 +02:00
Simon Hausmann
1d533641b4 Python: Fix name of helper method 2025-05-16 17:15:57 +02:00
Simon Hausmann
b1f0e5fe81 Python: Remove unused PyValueRef type 2025-05-16 17:15:57 +02:00
Simon Hausmann
d4439231eb Python: Upgrade to Pyo3 0.25 2025-05-16 17:15:57 +02:00
ogoffart
e0099ea500 Bump version number to 1.12.0 2025-04-30 13:27:50 +00:00
Simon Hausmann
a50b8f8793
FemtoVG: Add support for WGPU based rendering (#8268)
Enable via the `renderer-femtovg-wgpu` feature flag.

cc #171
2025-04-25 14:37:32 +02:00
Simon Hausmann
7c02bbd833
Python: Fix doc link 2025-04-23 21:40:48 +02:00
autofix-ci[bot]
8fcc320bdd [autofix.ci] apply automated fixes 2025-04-22 22:30:32 +02:00
Kavindra Palaraja
41366cf272 Python: Minor improvements to API descriptions 2025-04-22 22:30:32 +02:00
autofix-ci[bot]
c0bdfa7169 [autofix.ci] apply automated fixes 2025-04-22 22:30:32 +02:00
Kavindra Palaraja
cafa43ff22 Minor updates to the documentation for readability and polish 2025-04-22 22:30:32 +02:00
Simon Hausmann
5dc8410f0a Python: Fix mis-rendering 2025-04-22 16:24:21 +02:00