GUI和多线程

GUI和多线程

为了能够让分离的线程信息交流,我不得不使用Inter-Process-Communication(IPC),这是一种高级的用法。

Mutiple threads运行在相同的计算机存储空间,所以没必要使用IPC,IPC会增加我们的代码的复杂性。

使用线程,导入线程

from threading import Thread

oop = OOP()

runT= Thread(target = oop.methodInAThread)
oop.win.mainloop()

开始一个线程

新增自己的方法,然后调用方法通过回调函数,调用自己的方法,callback function。

def createThread(self):
	runT = Thread(target=self.methodInAThread)
	runT.start()
def clickMe(self):
	self.action.configure(text='Hello ' + self.name.get())
	self.createThread()

猜你喜欢

转载自blog.csdn.net/qq_28485501/article/details/84679258