Commit graph

32 commits

Author SHA1 Message Date
Simon Hausmann
a98d4709be Move printer demo and energy-monitor into new top-level demos/ folder
These are showing off use-cases for Slint, but they're not examples showing individual Slint features.

Also removed the old printerdemo while at it.
2024-10-25 12:09:32 +02:00
Simon Hausmann
844590cac8
Python: Add support for snake case imports (#6229)
When using slint.loader.app_window.XXX look for "app_window.slint" followed by "app-window.slint".

Fixes #6216
2024-09-20 10:25:14 +02:00
Simon Hausmann
636de6fc7c Python: Fix support for named exports 2024-08-13 12:04:04 +02:00
Simon Hausmann
1e3f05c983 Python: Expose Slint structs
Structs declared and exported in Slint are now available in the module namespace
with a constructor.

Fixes #5708
2024-08-13 12:04:04 +02:00
Simon Hausmann
e3aab79fdb Python: Improve Struct mapping
When reading, create the local equivalent of a dataclass, so that access
doesn't require ["foo"] key syntax.

Also implement the copy protocol, so that we can safely make clones of
the references returned by the ListModel.
2024-07-11 22:08:10 +02:00
Simon Hausmann
0b6381d012 Python: Fix access to globals when there's more than one
The getter for the global didn't capture the correct global_class,
just the last iteration.

This fixes the broken printer demo.
2024-07-11 22:00:39 +02:00
Simon Hausmann
0c7d2062a5 Python: Add support for exporting multiple components 2024-07-02 10:52:22 +02:00
Simon Hausmann
624796d53e Python: Make the timer test more robust
It seems that with the latest winit, quit_event_loop() might take a little longer and the timer fires once more. We don't really care how long quit_event_loop() takes in this test, merely that the timer firest and that we can terminate the loop.

Fixes #5484
2024-06-27 09:58:14 +02:00
Simon Hausmann
b98035526b Python: Add the ability to invoke functions declared in Slint from Python 2024-06-05 14:06:10 -07:00
Aurindam Jana
3523e86359
Simplify commercial license (#3063)
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
2024-05-31 14:06:17 +02:00
Aurindam Jana
9a3aa265d5
Update Royalty-free license (#5257)
Add clarification that Application may not expose Slint APIs.
2024-05-31 10:53:19 +02:00
Simon Hausmann
f86f4993fa Python: Replace import magic with an auto-loader
As discussed on Reddit, the magic import logic is not very tool friendly and a little too magic perhaps. Instead, this patch introduces an automatic loader (`slint.loader`), which can traverse `sys.path` and lazily load `.slint` files by attribute lookup.

Closes #4856
2024-04-18 16:04:20 +02:00
Aurindam Jana
0cfeec1a31
Update Slint Community License (#4994)
Updated the version from 1.1 to 1.2 
Renamed the header to "Slint Royalty-free Desktop, Mobile, and Web Applications License"
Added definition of "Mobile Application" and grant of right
Moved "Limitations" to 3rd section and "License Conditions - Attributions" to 2nd section
Added flexibility to choose between showing "MadeWithSlint" as a dialog/splash screen or on a public webpage
Moved the para on copyright notices to section under "Limitations"
2024-04-15 15:18:55 +02:00
Simon Hausmann
c1e8d7c07d Python: Add missing write-back support for Models
Ooops :-)
2024-03-07 19:48:48 +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
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
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
Simon Hausmann
b4cddbbe18 Python: Add support for converting structs
They map to Python dicts.

cc #4202
2024-02-02 22:15:52 +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
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
73024beb98 Begin wrapping the component compiler 2023-12-21 12:57:35 +01:00