mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 14:51:15 +00:00
Python: Improve Struct mapping
When reading, create the local equivalent of a dataclass, so that access doesn't require ["foo"] key syntax. Also implement the copy protocol, so that we can safely make clones of the references returned by the ListModel.
This commit is contained in:
parent
0b6381d012
commit
e3aab79fdb
7 changed files with 103 additions and 25 deletions
|
@ -5,6 +5,7 @@ from slint import Color, ListModel, Timer, TimerMode
|
|||
import slint
|
||||
from datetime import timedelta, datetime
|
||||
import os
|
||||
import copy
|
||||
import sys
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
|
||||
|
||||
|
@ -48,13 +49,13 @@ class MainWindow(slint.loader.ui.printerdemo.MainWindow):
|
|||
def update_jobs(self):
|
||||
if len(self.printer_queue) <= 0:
|
||||
return
|
||||
top_item = self.printer_queue[0]
|
||||
top_item["progress"] += 1
|
||||
if top_item["progress"] >= 100:
|
||||
top_item = copy.copy(self.printer_queue[0])
|
||||
top_item.progress += 1
|
||||
if top_item.progress >= 100:
|
||||
del self.printer_queue[0]
|
||||
if len(self.printer_queue) == 0:
|
||||
return
|
||||
top_item = self.printer_queue[0]
|
||||
top_item = copy.copy(self.printer_queue[0])
|
||||
self.printer_queue[0] = top_item
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue