Joran比斯利有正确的答案,但过于复杂的方式事情。下面是简单的版本:
class Worker(threading.Thread):
def run(self):
# long process goes here
w = Worker()
w.start()
tkMessageBox.showinfo("Work Started", "OK started working")
w.join()
tkMessageBox.showinfo("Work Complete", "OK Done")
编辑:这里是它的一个工作示例:
import threading
import time
import tkMessageBox
import Tkinter as tk
root = tk.Tk()
root.withdraw()
class Worker(threading.Thread):
def run(self):
# long process goes here
time.sleep(10)
w = Worker()
w.start()
tkMessageBox.showinfo("Work Started", "OK started working")
root.update()
w.join()
tkMessageBox.showinfo("Work Complete", "OK Done")
这真棒,正是我想要的,谢谢! – lsp