Python: Add support for assigning colors directly to brushes

This commit is contained in:
Simon Hausmann 2024-03-06 16:20:05 +01:00
parent 3c9b57ecf8
commit 3e66b98121
3 changed files with 12 additions and 2 deletions

View file

@ -75,6 +75,10 @@ impl FromPyObject<'_> for PyValue {
ob.extract::<PyRef<'_, crate::brush::PyBrush>>()
.map(|pybrush| slint_interpreter::Value::Brush(pybrush.brush.clone()))
})
.or_else(|_| {
ob.extract::<PyRef<'_, crate::brush::PyColor>>()
.map(|pycolor| slint_interpreter::Value::Brush(pycolor.color.clone().into()))
})
.or_else(|_| {
ob.extract::<PyRef<'_, crate::models::PyModelBase>>()
.map(|pymodel| slint_interpreter::Value::Model(pymodel.as_model()))