Commit graph

139 commits

Author SHA1 Message Date
Florian Blasius
2355234553 Fixed typo in python readme 2024-03-08 10:32:10 +01:00
Simon Hausmann
c1e8d7c07d Python: Add missing write-back support for Models
Ooops :-)
2024-03-07 19:48:48 +01:00
Simon Hausmann
cc83784de5 Python: Remove link to milestone 1
Instead refer to the remaining tickets for now.
2024-03-07 17:51:00 +01:00
Simon Hausmann
2234878453 Python: Use kwargs passed to the instance constructors
And set properties, like in JavaScript.
2024-03-07 17:49:00 +01:00
Simon Hausmann
a3b7a6da50 Python: Beef up the README with an API overview and a quickstart 2024-03-07 17:38:36 +01:00
Simon Hausmann
6a6b70185f From the Python README, refer to the printer demo instead of the tests. 2024-03-07 12:12:24 +01:00
Simon Hausmann
a93e2be393 Python: Add support for a @slint.callback decorator to conveniently associated callbacks with python methods
cc #4134
2024-03-07 12:00:08 +01:00
Simon Hausmann
3b7b2411b4 Python: Add support for dynamic imports
```python
import foo_slint
```

will now also look for `foo.slint`
2024-03-07 10:08:12 +01:00
Simon Hausmann
176aa4bf72 Python: Make it possible to construct a ListModel from an iterable
Makes for a more pythonic API :)

cc #4135
2024-03-07 08:55:37 +01:00
Simon Hausmann
c83615cfb1 Python: Improve diagnostics when invoking a callback fails 2024-03-07 08:33:45 +01:00
Simon Hausmann
bdab1050f0 Python: Fix setters getters for properties/callacks
Make sure to capture the global/callback/property name correctly in
the closures.
2024-03-06 18:55:59 +01:00
Simon Hausmann
a29cc4ddf2 Python: Don't panic when invoking a python callback fails
Instead, log a message and return.
2024-03-06 18:55:23 +01:00
Simon Hausmann
b87cd69f47 Python: Don't panic when unable to convert an interpreter data type to Python
Print a warning and return None instead
2024-03-06 17:22:27 +01:00
Simon Hausmann
b075fa8acd Python: Expose Timer and TimerMode 2024-03-06 17:22:27 +01:00
Simon Hausmann
14b371beff Python: Expose the Model and ListModel in slint 2024-03-06 17:22:27 +01:00
Simon Hausmann
3e66b98121 Python: Add support for assigning colors directly to brushes 2024-03-06 17:22:27 +01:00
Simon Hausmann
3c9b57ecf8 Python: Create a property type wrapper for component instances
Map properties and callbacks to attributes with getters and setters.

cc #4134
2024-03-06 17:20:30 +01:00
Simon Hausmann
765c773b90 Python: rework the load_file API, part 2
Take arguments for configuring style, etc., throw an exception on errors, and log warning diagnostics.
2024-03-06 13:10:54 +01:00
Simon Hausmann
280f314eeb Python: Rework the load_file API, part 1
Return a namespace that contains a "class type" for
constructing the component instance - similar to the Node.js
API.
2024-03-06 13:10:54 +01:00
Simon Hausmann
2f313f84ec 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
2024-03-05 15:45:52 +01:00
Simon Hausmann
1b17fe3c1d Python: Fix GC support for callbacks
Make the references to the callbacks visible to the GC
to be able to break cycles.
2024-03-04 15:42:37 +01:00
Simon Hausmann
80fda11e0f Python: Add bindings for Brush and Color
cc #4202
2024-03-01 17:17:44 +01:00
Simon Hausmann
93efd74e24 Add support for mapping image properties
This exposes a slint.Image class, which has a load_from_path class
method as well as size/width/height properties.

cc #4202
2024-02-23 16:05:07 +01:00
ogoffart
a0eed4e58e Bump version number to 1.5.0 2024-02-20 17:33:11 +00:00
Simon Hausmann
b4cddbbe18 Python: Add support for converting structs
They map to Python dicts.

cc #4202
2024-02-02 22:15:52 +01:00
ogoffart
fec2b961db Bump version number to 1.4.1 2024-02-01 09:12:42 +00:00
Simon Hausmann
5d3ad7b252 Python: Fix venv setup
A subtly missing letter :)
2024-01-31 17:04:06 +01:00
Simon Hausmann
d1529af3cc python: hide native module behind python front-end API
Encapsulate the rust code behind a public API (in __init__.py for now)
2023-12-21 12:57:35 +01:00
Simon Hausmann
07c168bbf9 python: Clean up Cargo.toml
Remove unused dependencies and fetch needed ones from the workspace. We'll sort out the substituation with crates.io dependencies later when packaging.
2023-12-21 12:57:35 +01:00
Simon Hausmann
2c6af79104 Add a barebones README 2023-12-21 12:57:35 +01:00
Simon Hausmann
fb76502cf4 Run python tests without capturing stderr/stdout
... so that we can see backtraces
2023-12-21 12:57:35 +01:00
Simon Hausmann
33a1d07226 Add support for timers and run/quit_event_loop 2023-12-21 12:57:35 +01:00
Simon Hausmann
e4785220ef Add a little test for manual trying :) 2023-12-21 12:57:35 +01:00
Simon Hausmann
08461d7b32 Convert None to Void correctly 2023-12-21 12:57:35 +01:00
Simon Hausmann
82c2728cfd Add show/hide/run to component instance 2023-12-21 12:57:35 +01:00
Simon Hausmann
644ebbb2aa Split value conversion into a separate module 2023-12-21 12:57:35 +01:00
Simon Hausmann
10d6aa199c Split errors out into a separate module 2023-12-21 12:57:35 +01:00
Simon Hausmann
73024beb98 Begin wrapping the component compiler 2023-12-21 12:57:35 +01:00
Simon Hausmann
a2054e7ebd Add boilerplate 2023-12-21 12:57:35 +01:00