#--------------------------------------------------------------------- # Esempio conferma chiusura finestra #--------------------------------------------------------------------- try: import Tkinter as tk # Py2 import tkMessageBox as messagebox except ImportError: import tkinter as tk # Py3 import tkinter.messagebox as messagebox #--------------------------------------------------------------------- class Applicazione: def __init__ (self): self.form1 = tk.Tk() self.form1.protocol("WM_DELETE_WINDOW", self.domanda) def domanda(self): if messagebox.askyesno("", "Chiudere veramente?"): self.form1.destroy() def start(self): self.form1.mainloop() #--------------------------------------------------------------------- Applicazione().start()