我试图将文件从FTP下载到网络共享文件夹(文件大小可能是500mb或更大),但每次单击“开始”时,GUI将显示“没有响应”,即使使用QThread
我做错什么了吗?在
在主.py在
# -*- coding: utf-8 -*-
from PyQt4 import QtGui
import ftp100
class main_windows(QtGui.QWidget):
def __init__(self):
super(main_windows, self).__init__()
self._count = 0
self.Ftpallobject = []
def init(self):
#PASS SOME GUI CODE
button_go = QtGui.QPushButton('GO')
button_go.clicked.connect(self.Ftpstart)
self.fp = ftp100.ftpmethod()
self.fp.requestSignal_getinfo.connect(self.Ftpallobject)
def SendFtpInfo(self):
self.fp.update_getinfo.emit(self.allobject)
def Ftpstart(self):
self.fp.run()
在ftp.py文件在
^{pr2}$
你确实做错了。在
现在要做的是直接调用
run
-方法,而不是调用start()
,因此正确的实现应该是:当子类化
QThread
(或普通python线程)时,实现run
-方法,它表示线程应该做的工作,如果直接调用它,则在current线程中执行该代码(在本例中是主线程)。这就是为什么您的GUI将变得无响应。在{{cd2>如果一个线程不存在,那么它将首先调用一个新的。来自PyQT Documentation:
对于
run()
相关问题 更多 >
编程相关推荐