在python中退出mainloop

在python中退出mainloop,第1张

在python中退出mainloop

致电

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



欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/4931881.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-13
下一篇2022-11-13

发表评论

登录后才能评论

评论列表(0条)

    保存