tjy/demo/core/update_thread.py

25 lines
648 B
Python

from PyQt5.QtCore import QThread, pyqtSignal
class UpdateThread(QThread):
update_ui_signal = pyqtSignal(dict)
def __init__(self, ai_process):
super().__init__()
self.ai_process = ai_process
self.running = True
def run(self):
while self.running:
results = self.ai_process.get_results()
if results:
self.update_ui_signal.emit(results)
self.msleep(100) # 休眠100ms
def update_ui(self, results):
print(results)
self.update_ui_signal.emit(results)
pass
def stop(self):
self.running = False
self.wait()