我正在尝试以下方法:
import Tkinter as tk
root = tk.Tk()
root.withdraw()
box = tk.Toplevel()
box.title('My title')
tk.Message(box, text='My message').pack()
for i in range(100000000):
pass
box.destroy()
当我从交互式解释器发出这些语句时,一切都很好并且会显示消息。但是,当我将其作为脚本运行时,不会显示该消息。我错过了什么?
答案 0 :(得分:0)
以下作品:
import Tkinter as tk
root = tk.Tk()
root.withdraw()
box = tk.Toplevel()
box.title('My title')
tk.Message(box, text='My message').pack()
root.update() # this is the important line; may need it inside the loop
for i in range(100000000):
pass
box.destroy()