def on_close():
if self.editor_views:
next(iter(self.editor_views.values())).root.lift()
- elif (
- not self.controller.dirty
- or messagebox.askokcancel("Confirm", "You have unsaved changes. Quit anyway?")
- ):
- self.controller.save_state()
+ elif self.controller.dirty:
+ result = messagebox.askyesnocancel("Confirm", "You have unsaved changes. Save before exiting?")
+ if result is True:
+ self.controller.save_state()
+ if result is not None:
+ self.root.destroy()
+ else:
self.root.destroy()
self.root.protocol('WM_DELETE_WINDOW', on_close)
self.parent_view = parent_view
def on_close():
- do = not self.dirty or messagebox.askokcancel("Confirm", "Discard changes?")
- if do:
+ if self.dirty:
+ result = messagebox.askyesnocancel("Confirm", "Save data before closing?")
+ if result is True:
+ on_ok()
+ elif result is False:
+ self.finish()
+ else:
self.finish()
self.root = tk.Toplevel(parent)
self.root.resizable(False, False)