from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys,time
class MyThread(QThread):
def __init__(self):
super(MyThread,self).__init__()
def run(self):
print 4
#for i in range(10):
#mainwin.textedit.setText(QString("%1").arg(3))
class MainWin(QWidget):
def __init__(self):
super(MainWin,self).__init__()
self.resize(200,200)
self.button = QPushButton("Start",self)
self.button.setGeometry(60,100,80,30)
self.textedit = QTextEdit(self)
self.textedit.setGeometry(30,10,140,70)
self.connect(self.button,SIGNAL("clicked()"),self.process)
def process(self):
mythread = MyThread()
mythread.start()
if __name__ == "__main__":
app = QApplication(sys.argv)
mainwin = MainWin()
mainwin.show()
app.exec_()
请问是不是一定要在主线程里面加wait?如果这样的话,那gui岂不是一样会看上去死掉?