Keep multi-account refresh responsive and batch monster feeding
This commit is contained in:
@@ -1,5 +1,42 @@
|
||||
"""Native number inputs and scrollbars with usable click targets."""
|
||||
from PySide6 import QtCore as C, QtGui as G, QtWidgets as W
|
||||
import time
|
||||
|
||||
|
||||
class RowBatch(C.QObject):
|
||||
"""Create Qt rows in short event-loop slices, keeping input responsive."""
|
||||
def __init__(self, parent):
|
||||
super().__init__(parent)
|
||||
self.timer = C.QTimer(self)
|
||||
self.timer.setInterval(1)
|
||||
self.timer.timeout.connect(self.tick)
|
||||
self.running = False
|
||||
|
||||
def start(self, rows, apply, finished):
|
||||
self.stop()
|
||||
self.rows, self.apply, self.finished = iter(rows), apply, finished
|
||||
self.running = True
|
||||
self.tick()
|
||||
if self.running:
|
||||
self.timer.start()
|
||||
|
||||
def stop(self):
|
||||
self.timer.stop()
|
||||
self.running = False
|
||||
|
||||
@C.Slot()
|
||||
def tick(self):
|
||||
until = time.perf_counter() + .008
|
||||
count = 0
|
||||
while self.running and count < 24 and time.perf_counter() < until:
|
||||
try:
|
||||
row = next(self.rows)
|
||||
except StopIteration:
|
||||
self.stop()
|
||||
self.finished()
|
||||
return
|
||||
self.apply(row)
|
||||
count += 1
|
||||
|
||||
|
||||
class IntegerInput(W.QLineEdit):
|
||||
|
||||
Reference in New Issue
Block a user