Simon Hausmann
d36124f248
CI: Fix python ty runs with latest ty beta
...
- Add missing cast
- Fix unnecessary cast in test_load_file.py
2025-12-18 09:29:51 +01:00
autofix-ci[bot]
590c9b7864
[autofix.ci] apply automated fixes
autofix.ci / format_fix (push) Waiting to run
autofix.ci / lint_typecheck (push) Waiting to run
autofix.ci / ci (push) Blocked by required conditions
2025-12-09 12:11:04 +01:00
David Faure
41be30ee6a
Port from vec![] to Vec::new()
...
autofix.ci / format_fix (push) Waiting to run
autofix.ci / lint_typecheck (push) Waiting to run
autofix.ci / ci (push) Blocked by required conditions
vec![] expands to Vec::new(), but expanding macros takes a bit of
time and takes memory in rust-analyzer. Also, the code was using a mix
of vec![] and Vec::new(), so this is more consistent.
2025-12-05 16:53:45 +01:00
Olivier Goffart
4b9017e513
translations: set the translation dirty when setting the translator
2025-12-05 09:56:13 +01:00
Olivier Goffart
84759dc02b
Fix html-like comments to be on two lines
2025-12-04 21:58:09 +01:00
Olivier Goffart
88697c68bb
Remove license header from .md/.mdx files
...
They should be in the lines, but the problem is that this causes issues
in the .mdx files.
License header doesn't really make sense for .md files anyway
2025-12-04 21:58:09 +01:00
Simon Hausmann
d903afecef
Python: Fix tests in the CI having difficulties connecting to Xvfb
...
Instead of connecting to the X server, let's run the Python tests with the testing backend, like we do for test-driver-rust, test-driver-cpp, etc.
When building the Python package, pass --features backend-testing to Cargo, to forward to enabling the backend-testing feature in i-slint-backend-selector. That consequently enables SLINT_BACKEND=testing.
2025-11-30 10:02:36 +01:00
Simon Hausmann
16a96399b5
Python: Unpin ty type checker version
...
Match the name of the argument to please the type checker.
2025-11-26 11:30:10 +01:00
YuxuanYan
7bad0c4828
Error message for using a python callback decorator on an async callback not being declared ( #10152 )
...
* Error message for using a python callback decorator on an async callback not being declared
2025-11-25 08:43:02 +01:00
Simon Hausmann
dbe2c59ce9
Python: Fix support for underscores in async callback decorators
...
autofix.ci / format_fix (push) Has been cancelled
autofix.ci / lint_typecheck (push) Has been cancelled
autofix.ci / ci (push) Has been cancelled
Fixes #10024
2025-11-22 14:03:42 +01:00
Simon Hausmann
feecce73ad
Python: Speed up testing
...
Build editable builds as cargo debug builds, not release. This is faster
(because we don't need LTO) and in theory gives additional coverage to
debug asserts.
2025-11-21 09:48:42 +01:00
Simon Hausmann
f2dc010dbf
Python: Speed up testing
...
Separate steps and remove nox, so that
1. We first set up the env and build slint **once**
2. We run the fast lint/ty/etc. checks
3. We run the python tests directly
2025-11-20 20:51:54 +01:00
Simon Hausmann
831e067f98
Python: Use ty instead of mypy
...
It has gotten pretty good and it's much faster than mypy.
2025-11-20 20:51:54 +01:00
Simon Hausmann
16ceb115a1
slint-compiler: Add support for generating Python stubs ( #10123 )
...
The generated file offers the following two pieces of functionality:
- Convenient front-end to slint.load_file() by loading the .slint file
(replaces use of auto-loader)
- More importantly: Type information for exported properties, callbacks,
functions, and globals
On loading, the previously generated API is compared to what's in the
.slint file and if the .slint file was changed in an incompatible way,
an exception is thrown.
A Python test driver is added which performs three steps with each test
case:
1. Generate python stubs and checks that they can be loaded with the
python interpreter and that `uv ty check` passes.
2. Extract expected python API out of pyi sections and compares them.
3. Appends any python code from python sections and runs them (this is
combined with step 1)
Fixes #4136
2025-11-20 17:17:01 +01:00
Simon Hausmann
c3b020eed8
compiler: Move Struct's node field into the name enum
...
That guarantees the symmetry that if a struct is user defined, we're guaranteed to have a syntax node.
2025-11-18 20:35:05 +01:00
Simon Hausmann
d2f294cf3d
compiler: Remove unnecessary StructName::User checks
...
The node check covers this already.
2025-11-18 20:35:05 +01:00
Simon Hausmann
5cd505b9ac
compiler: Change Struct::name to be an enum instead of a string
...
For the future Python generate, we need to know if a struct type is a
public Slint type, private perhaps, or custom. Instead of continuing
with string operations, an enum gives clarity what's what, and this also
emits removing some string matching to identify specific types.
2025-11-18 20:35:05 +01:00
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
...
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()
...
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
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