【发布时间】:2019-05-03 21:32:14
【问题描述】:
在下面的程序中,我可以使用关闭按钮关闭窗口,但既不能使用“Esc”绑定,也不能使用按钮回调。我被发送到 IPython 控制台,但窗口仍停留在此处,并带有一个旋转的轮子!在终端或 Anaconda IDLE 中运行良好。我使用的是 Mac、High Sierra、Anaconda 和 Spyder 的最新版本(IPython 7.1.1、Spyder 3.3.2)。我怀疑 Spyder 有问题。
from tkinter import *
class Myapp(object):
def __init__(self):
self.root = Tk()
self.root.geometry('150x100+1+1')
self.root.title('Root')
self.root.bind('<Escape>', lambda e: self.root.destroy())
self.button = Button(self.root, text='End Program', command=self.end)
self.button.place(x=10, y=45)
self.L = [1,2,3] # result of an omitted computation
def end(self):
self.root.destroy()
app = Myapp()
app.root.mainloop()
print(app.L)
有什么提示吗?谢谢。
【问题讨论】: