Added question dialog for unsaved close
authoretisserant
Thu, 28 Feb 2008 18:12:16 +0100
changeset 119 f3819d2e8eff
parent 118 185d0d371ea4
child 120 8c3150858dd3
Added question dialog for unsaved close
Beremiz.py
--- a/Beremiz.py	Wed Feb 27 18:40:39 2008 +0100
+++ b/Beremiz.py	Thu Feb 28 18:12:16 2008 +0100
@@ -395,8 +395,19 @@
                 event.Veto()
                 return
             if self.PluginRoot.ProjectTestModified():
-                self.PluginRoot.SaveProject()
-                wx.MessageBox("Project saved")
+                dialog = wx.MessageDialog(self, "There are changes, do you want to save?", "Close Application", wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION)
+                answer = dialog.ShowModal()
+                dialog.Destroy()
+                if answer == wx.ID_YES:
+                    self.PluginRoot.SaveProject()
+                    event.Skip()
+                    return
+                elif answer == wx.ID_NO:
+                    event.Skip()
+                    return
+                else:
+                    event.Veto()
+                    return
         event.Skip()
     
     def OnMoveWindow(self, event):