Reputation: 155
I create a window with Tkinter. When I click the quit button, windows shows the exe stop working. Could any one tell me why this happens? I think the problem is the self.quit, but I do not know the reason.
Here is the codes.
from Tkinter import *
class App(Frame):
def __init__(self, master = None):
Frame.__init__(self, master)
self.pack()
self.createWidgets()
def createWidgets(self):
self.Quit = Button(self, text = "QUIT", command = self.quit)
self.Quit.pack(side = LEFT)
root = Tk()
app =App(master = root)
app.mainloop()
Upvotes: 0
Views: 2710
Reputation: 20689
In the quit button, you are calling the quit()
method of Frame
. In its place, you need to call destroy()
on the root element to finish the mainloop correctly.
self.Quit = Button(self, text = "QUIT", command = self.master.destroy)
Upvotes: 1