【发布时间】:2018-06-14 14:32:03
【问题描述】:
我遇到了一个 pyqtSignal 通过线程的问题。 我收到以下错误:
AttributeError: 'PyQt5.QtCore.pyqtSignal' object has no attribute 'connect'
关于命令:
CALCULS_AE.Uni_finished.connect(self.getFinishThread())
该程序基本上是一个使用 PyQt Designer 设计的主窗口,并通过线程调用几个不同的函数。 我想在我的 MainWindow 代码中获得一些线程的完成信号(以显示结果等......)。下面是解释其架构的一小部分代码。
主要代码:
class MainWindow(QMainWindow, Ui_MainWindow):
def __init__(self):
#Some code...
self.Button.clicked.connect(self.launch_Calculation_clicked)
def launch_Calculation(self):
AE_Uni_thread = threading.Thread(target = CALCULS_AE.Calcul_AE_Uni, args = (arg1, arg2, arg3, arg4)) # Calculs_AE is a class defined in another file
CALCULS_AE.Uni_finished.connect(self.getFinishThread()) # Another function doing some other stuff with the thread's results
AE_Uni_thread.start()
开始计算的类CALCULS_AE:
class CALCULS_AE(object):
#Signals
Uni_finished = QtCore.pyqtSignal()
Reb_finished = QtCore.pyqtSignal()
def __init__(self):
# Some Code
def Calculs_AE_Uni(self, arg1, arg2, arg3, arg4):
# Some Code launching the calculation
self.Uni_finished.emit()
PS : pyqtSignals 是在文档中指定的类级别上定义的。
谢谢!
【问题讨论】:
-
你需要创建一个
CALCULS_AE的实例。
标签: python multithreading pyqt5