# 线程函数
class WorkerThread(QThread): resultReady = pyqtSignal(object) def __init__(self, func, *args, **kwargs): super().__init__() self.func = func self.args = args self.kwargs = kwargs def run(self): self.result = self.func(*self.args, **self.kwargs) self.resultReady.emit(self.result) # 返回执行的结果 def get_result(self): return self.result # 主函数 class Main(QWidget, Ui_Form): def __init__(self): super(Main, self).__init__() self.setupUi(self) # 重新连接 self.pushButton_2.clicked.connect(lambda: self.runCheck()) self.textEdit.setReadOnly(True) # 设置为只读 QTimer.singleShot(0, self.runCheck) # 延迟执行
# 使用线程执行函数 def runCheck(self): self.thread = WorkerThread(self.check) self.thread.start() def print(self): self.textEdit.append("19237012 入库成功") # 检测函数 def check(self): """" 逻辑业务函数 """
标签:__,函数,self,PYQT5,init,线程,result,卡死,def From: https://www.cnblogs.com/wanghong1994/p/17626525.html