Why "quit" command doesn't work?

1.5k views Asked by At

I've been experiencing trouble with "quit" command in my Python (3.4.3, Windows 64 bits) and currently isn't working at all. It always fail and, whenever I try to use it along with tkinter module, my code freezes, my Python crashes and I have to restart the shell. Look at this simple example... Could anybody tell what is wrong with this?

from tkinter import *
top = Tk()
quit_button = Button(top, text='Quit', command=quit).pack()
mainloop()
2

There are 2 answers

3
Sam Krygsheld On

Just tested your code, and I am having the same issue. The quit command should be top.quit, but that didn't work either. However, command=top.destroy worked fine for me, so if that is acceptable for you situation, try that out.

0
Guseyn013 On

You had to write command=top.quit, not just command=quit. There is your mistake.