mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 05:44:52 +00:00
Python: Make it possible to construct a ListModel from an iterable
Makes for a more pythonic API :) cc #4135
This commit is contained in:
parent
c83615cfb1
commit
176aa4bf72
2 changed files with 18 additions and 2 deletions
|
@ -25,9 +25,12 @@ class Model(native.PyModelBase):
|
|||
|
||||
|
||||
class ListModel(Model):
|
||||
def __init__(self, lst=None):
|
||||
def __init__(self, iterable=None):
|
||||
super().__init__()
|
||||
self.list = lst or []
|
||||
if iterable is not None:
|
||||
self.list = list(iterable)
|
||||
else:
|
||||
self.list = []
|
||||
|
||||
def row_count(self):
|
||||
return len(self.list)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue