我很难开始使用Tkinter。尝试关闭时,我所有的窗户似乎崩溃了。 (也就是说,它们以IDLE的形式将执行返回给提示符,但窗口保持打开状态,并且退出按钮保持按下状态。窗口没有响应,必须在Windows中手动将其终止。)最直接的例子是《快速Python书籍》一书。这是代码:
from tkinter import *
import sys
win = Tk()
b = Button(win, text="Goodbye",command=sys.exit)
b.pack()
mainloop()
Python给我以下错误消息:
Traceback (most recent call last):
File "C:/Python Scripts/Quick Python Practice Programs/TKinter Practice.py", line
6, in <module>
mainloop()
File "C:\Python32\lib\tkinter\__init__.py", line 317, in mainloop
_default_root.tk.mainloop(n)
File "C:\Python32\lib\tkinter\__init__.py", line 1401, in __call__
raise SystemExit(msg)
SystemExit
我从IDLE外壳程序中调用它,并且我很确定它没有设置为== No Subprocesses ==。重新启动外壳程序时,我得到== Restart ==。
任何帮助将不胜感激。
[我认为您看到的是与在IDLE中运行有关的内容-独立的Tkinter脚本不会表现出这种现象。
[在IDLE下运行时,将其作为异常处理。