ERIC6 线程
本文禁止转载
from PyQt5.QtCore import QThread, pyqtSignal class RunThread(QThread): trigger = pyqtSignal() def __init__(self, parent=None): super(RunThread, self).__init__() def __del__(self): self.wait() def run(self): 耗时主程序内容 self.trigger.emit() class Dialog(QDialog, Ui_Dialog): def __init__(self, parent=None): super(Dialog, self).__init__(parent) self.setupUi(self) def Work(self): self.thread = RunThread() self.thread.start() def w(): 耗时主程序结束后内容 self.thread.trigger.connect(w) @pyqtSlot() def on_pushButton_clicked(self): self.Work() if __name__ == "__main__": import sys app =QApplication(sys.argv) ui = Dialog() ui.show() sys.exit(app.exec_())
===今日我言===========
勇气 让人进步
===================