Slint Python API
Slint ↗ is a UI toolkit that supports different programming languages. Slint-python is the integration with Python.
This documentation describes slint 1.17.0b1.
Prerequisites
Section titled “Prerequisites”- Python 3 ↗
- uv ↗ or pip ↗
Installation
Section titled “Installation”Install Slint with uv or pip from the Python Package Index ↗:
uv add slintThe installation uses binaries provided for macOS, Windows, and Linux for
various architectures. If your target platform is not covered by binaries, uv
will automatically build Slint from source. If that happens, you will need some
software development tools on your machine, as well as
Rust ↗.
Quick start
Section titled “Quick start”- Create a new project with
uv init. - Add the Slint Python package to your project:
uv add slint. - Create a file called
app-window.slint:
import { Button, VerticalBox } from "std-widgets.slint";
export component AppWindow inherits Window { in-out property<int> counter: 42; callback request-increase-value(); VerticalBox { Text { text: "Counter: \{root.counter}"; } Button { text: "Increase value"; clicked => { root.request-increase-value(); } } }}- Create a file called
main.py:
import slint
# slint.loader will look in `sys.path` for `app-window.slint`.class App(slint.loader.app_window.AppWindow): @slint.callback def request_increase_value(self): self.counter = self.counter + 1
app = App()app.run()- Run it with
uv run main.py.
Instantiating a component
Section titled “Instantiating a component”Exported components are exposed as Python classes. To access such a class, you have two options:
-
Call
load_file. The returned object is a namespace ↗ that provides every exported component that inheritsWindow:import slintcomponents = slint.load_file("app.slint")main_window = components.MainWindow()python -
Use Slint’s auto-loader, which lazily loads
.slintfiles fromsys.path:import slintmain_window = slint.loader.app.MainWindow()python
Callbacks
Section titled “Callbacks”Callbacks declared in .slint files are visible as callable properties on the
component instance. Assign a Python callable to set a handler, or use the
callback decorator when sub-classing:
import slint
class Component(slint.loader.my_component.MyComponent): @slint.callback def clicked(self): print("hello")
component = Component()Arrays and models
Section titled “Arrays and models”Set array properties from Python by passing subclasses of Model.
Use ListModel to construct a model from an iterable:
component.model = slint.ListModel([1, 2, 3])component.model.append(4)del component.model[0]Type mappings
Section titled “Type mappings”Each type used for properties in the Slint language translates to a specific Python type:
.slint type | Python type |
|---|---|
int | int |
float | float |
string | str |
color | Color |
brush | Brush |
image | Image |
styled-text | StyledText |
data-transfer | DataTransfer |
length, physical-length, duration, angle | float |
| structure | dict / Struct |
| array | Model |
For the full set of classes and module-level functions, see the API section in the sidebar.
© 2026 SixtyFPS GmbH