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

@ -31,7 +31,7 @@ def test_property_access():
in property <bool> boolprop: true;
in property <image> imgprop;
in property <brush> brushprop: Colors.rgb(255, 0, 255);
in property <color> colprop;
in property <color> colprop: Colors.rgb(0, 255, 0);
in property <[string]> modelprop;
in property <MyStruct> structprop: {
title: "builtin",
@ -104,6 +104,12 @@ def test_property_access():
brushval = instance.get_property("brushprop")
assert str(brushval.color) == "argb(255, 128, 128, 128)"
brushval = instance.get_property("colprop")
assert str(brushval.color) == "argb(255, 0, 255, 0)"
instance.set_property("colprop", Color("rgb(128, 128, 128)"))
brushval = instance.get_property("colprop")
assert str(brushval.color) == "argb(255, 128, 128, 128)"
with pytest.raises(ValueError, match="no such property"):
instance.set_global_property("nonexistent", "theglobalprop", 42)
with pytest.raises(ValueError, match="no such property"):