Python-Threading与PyQt

Python-Threading与PyQt,python,multithreading,pyqt,Python,Multithreading,Pyqt,我是Python上线程使用的新手,我需要这方面的帮助 我使用的是PyQt,当我使用循环时,主窗口将被冻结,直到循环完成 我读过python上的线程技术,它似乎是一种解决方案,但我不知道我在代码中编写的线程技术是否适用 这是我的代码示例 from Window import * import sys, threading class Window(QtGui.QDialog): def __init__(self, parent=None): QtGui.QWidget.

我是Python上线程使用的新手,我需要这方面的帮助

我使用的是PyQt,当我使用循环时,主窗口将被冻结,直到循环完成

我读过python上的线程技术,它似乎是一种解决方案,但我不知道我在代码中编写的线程技术是否适用

这是我的代码示例

from Window import *
import sys, threading

class Window(QtGui.QDialog):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Window()
        self.ui.setupUi(self)
        QtCore.QObject.connect(self.ui.button_download,   QtCore.SIGNAL('clicked()'), start)

print("I'm the main thread")

def start():
    t1 = threading.Thread(target=process)
    t1.start()
    t1.join()

def process():
    for i in range(0, 1000):
        print("I'm the thread:", i)

if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    myapp = Window()
    myapp.show()
    sys.exit(app.exec_())

非常感谢

您正在立即加入线程。如果希望它在后台运行,请删除该行

t1.join()