I want to show a message box dialog when pressing the "X" button to close the GUI. I want to ask the user if he's sure he wants to exit the program with a Yes/No choice. I'm getting an error when I press "Yes" in the dialog and the GUI closes if I press "NO". This is the full code
This is the error I'm getting:
self.tk.call('destroy', self._w)
_tkinter.TclError: can't invoke "destroy" command: application has been destroyed
This is what I've done so far:
import atexit
def deleteme():
result = messagebox.askquestion("Exit", "Are You Sure You Want to Exit?")
if result == "yes":
root.destroy()
else:
return None
atexit.register(deleteme)