
root.quit(),而不是
theMainframe.quit:
import Tkinter as tkclass CloseAfterFinishframe1(tk.frame): # Diz que herda os parametros de frame def __init__(self, master): self.master = master tk.frame.__init__(self, master) # Inicializa com os parametros acima!! tk.Label(self, text="Hi", font=("Arial", 16)).pack() self.button = tk.Button(self, text="I am ready", command=self.CloseWindow, font=("Arial", 12)) self.button.pack() self.pack() def CloseWindow(self): # disable the button so pressing <SPACE> does not call CloseWindow again self.button.config(state=tk.DISABLED) self.forget() CloseAfterFinishframe2(self.master)class CloseAfterFinishframe2(tk.frame): # Diz que herda os parametros de frame def __init__(self, master): tk.frame.__init__(self, master) # Inicializa com os parametros acima!! tk.Label(self, text="Hey", font=("Arial", 16)).pack() button = tk.Button(self, text="the End", command=self.CloseWindow, font=("Arial", 12)) button.pack() self.pack() def CloseWindow(self): root.quit()root = tk.Tk()CloseAfterFinishframe1(root)root.mainloop()此外,
CloseEnd如果您只想调用函数,则无需创建类
root.quit。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)