mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-27 05:44:08 +00:00
WIP
This commit is contained in:
parent
604450da47
commit
fc50bd6806
4 changed files with 93 additions and 14 deletions
|
@ -7,21 +7,22 @@ from datetime import timedelta, datetime
|
|||
import os
|
||||
import copy
|
||||
import sys
|
||||
import printerdemo
|
||||
import typing
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
|
||||
|
||||
PrinterQueueItem = slint.loader.ui.printerdemo.PrinterQueueItem
|
||||
PrinterQueueItem = printerdemo.PrinterQueueItem
|
||||
InkLevel = printerdemo.InkLevel
|
||||
|
||||
|
||||
class MainWindow(slint.loader.ui.printerdemo.MainWindow):
|
||||
def __init__(self):
|
||||
class MainWindow(printerdemo.MainWindow):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.ink_levels = ListModel(
|
||||
[
|
||||
{"color": Color("#0ff"), "level": 0.4},
|
||||
{"color": Color("#ff0"), "level": 0.2},
|
||||
{"color": Color("#f0f"), "level": 0.5},
|
||||
{"color": Color("#000"), "level": 0.8},
|
||||
InkLevel(color=Color("#0ff"), level=0.4),
|
||||
InkLevel(color=Color("#ff0"), level=0.2),
|
||||
InkLevel(color=Color("#f0f"), level=0.5),
|
||||
InkLevel(color=Color("#000"), level=0.8),
|
||||
]
|
||||
)
|
||||
# Copy the read-only mock data from the UI into a mutable ListModel
|
||||
|
@ -33,11 +34,11 @@ class MainWindow(slint.loader.ui.printerdemo.MainWindow):
|
|||
)
|
||||
|
||||
@slint.callback
|
||||
def quit(self):
|
||||
def quit(self) -> None:
|
||||
self.hide()
|
||||
|
||||
@slint.callback(global_name="PrinterQueue", name="start_job")
|
||||
def push_job(self, title):
|
||||
def push_job(self, title: str) -> None:
|
||||
self.printer_queue.append(
|
||||
PrinterQueueItem(
|
||||
status="waiting",
|
||||
|
@ -51,12 +52,13 @@ class MainWindow(slint.loader.ui.printerdemo.MainWindow):
|
|||
)
|
||||
|
||||
@slint.callback(global_name="PrinterQueue")
|
||||
def cancel_job(self, index):
|
||||
def cancel_job(self, index: int) -> None:
|
||||
del self.printer_queue[index]
|
||||
|
||||
def update_jobs(self):
|
||||
def update_jobs(self) -> None:
|
||||
if len(self.printer_queue) <= 0:
|
||||
return
|
||||
assert self.printer_queue[0] is not None
|
||||
top_item = copy.copy(self.printer_queue[0])
|
||||
top_item.progress += 1
|
||||
if top_item.progress >= 100:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue