PLCOpenEditor.py
changeset 4 2de7fd952fdd
parent 3 86ccc89d7b0b
child 5 f8652b073e84
--- a/PLCOpenEditor.py	Thu Feb 08 17:41:41 2007 +0100
+++ b/PLCOpenEditor.py	Wed Mar 21 16:12:08 2007 +0100
@@ -582,7 +582,20 @@
         event.Skip()
 
     def OnGenerateProgramMenu(self, event):
-        self.Controler.GenerateProgram()
+        dialog = wxFileDialog(self, "Choose a file", os.getcwd(), "",  "ST files (*.st)|*.st|All files|*.*", wxSAVE|wxCHANGE_DIR)
+        if dialog.ShowModal() == wxID_OK:
+            filepath = dialog.GetPath()
+            if os.path.isdir(os.path.dirname(filepath)):
+                result = self.Controler.GenerateProgram(filepath)
+                if not result:
+                    message = wxMessageDialog(self, "Can't generate program to file %s!"%filepath, "Error", wxOK|wxICON_ERROR)
+                    message.ShowModal()
+                    message.Destroy()
+            else:
+                message = wxMessageDialog(self, "%s is not a valid folder!"%os.path.dirname(filepath), "Error", wxOK|wxICON_ERROR)
+                message.ShowModal()
+                message.Destroy()
+        dialog.Destroy()
         event.Skip()
 
     def SaveProject(self):