在使用tkMessageBox的同时摆脱toplevel tk panewindow

时间:2009-07-01 08:14:21

标签: python tkinter

link text

当我这样做时:

tkMessageBox.askquestion(title="Symbol Display",message="Is the symbol visible on the console")

以及符号显示窗口tk窗口也即将到来。

如果我按“是”...子窗口返回是,而tk窗口仍然存在。

每当我尝试关闭tk窗口时,End Program - tk都会出现。在推送“立即结束”按钮“pythonw.exe”窗口时,要求发送错误报告。

为什么会这样? 如何避免tk窗口弹出而不影响我的脚本执行???

1 个答案:

答案 0 :(得分:5)

技巧是在Tk根顶级调用撤销:

>>> import tkMessageBox, Tkinter
>>> Tkinter.Tk().withdraw()
>>> tkMessageBox.askquestion(
...     title="Symbol Display",
...     message="Is the symbol visible on the console")