from TKinter import * class Ui(Frame): def __init__(self) Frame.__init__(self, None) self.grid() bquit=Button(self, text="Quit", command=self.quit_pressed) bquit.grid(row=0, column=0) def quit_pressed(self): self.destroy() app=Ui() app.mainloop()
Why doesn't this Tkinter program end properly when I click the Exit button?
With self.destroy (), you simply destroy Frame, not the top-level container, you need to do self.master.destroy () so that it can exit correctly
, , , quit_pressed. , , - , . - , , , , . - , .
def quit_pressed(self): self.destroy() #This destroys the current self frame, not the root frame which is a different frame entirely
, ,
def quit_pressed(self): quit() #This will kill the application itself, not the self frame.