我对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_())
非常感谢!!你知道吗
你马上就要接线了。如果你想让它在后台运行,那么就删除行
相关问题 更多 >
编程相关推荐