Python: Make it possible to construct a ListModel from an iterable

Makes for a more pythonic API :)

cc #4135
This commit is contained in:
Simon Hausmann 2024-03-07 08:55:37 +01:00
parent c83615cfb1
commit 176aa4bf72
2 changed files with 18 additions and 2 deletions

View file

@ -83,6 +83,19 @@ def test_python_model_sequence():
assert model[2] == 3
def test_python_model_iterable():
def test_generator(max):
i = 0
while i < max:
yield i
i += 1
model = models.ListModel(test_generator(5))
assert len(model) == 5
assert list(model) == [0, 1, 2, 3, 4]
def test_rust_model_sequence():
compiler = native.ComponentCompiler()