Skip to content Skip to sidebar Skip to footer

Python Tkinter Toplevel .destroy() Vs .quit() Not Working As Intended

I have a class Duplicates that checks for duplicates within 40 words. I have a class Window that creates and runs the main window where i post the result. I have a class popWindow

Solution 1:

If you call destroy() on a toplevel window, it will not stop the application from running. If your application stops, there must be more to your code that what you're telling us. Without question, the right way to get rid of the popup is to call destroy on the instance of the Toplevel.

Solution 2:

A way to hide the window and keep the program running would be to use .withdraw() on the window, and .reiconify() to get it back (if needed). Or you could use .destroy() on a Toplevel window. If you need examples just ask, hope this helps you.

Solution 3:

The solution for me was:

deftopLevel_exit(self):
    self.top.quit()
    self.top.destroy()

I do not know if this is common praxis but is what I had to do since destroy was not stoping my top.mainloop()

Solution 4:

If you use a topLevel window, self.pop.destroy() should still work as you are using mainloop() Otherwise use quit() or both but in my opinion of all of these, I prefer destroy()

Post a Comment for "Python Tkinter Toplevel .destroy() Vs .quit() Not Working As Intended"