- dlg = wxTextEntryDialog (self, "Name for new project:", "New Project",
- "New project", wxOK | wxCANCEL)
- if dlg.ShowModal() == wxID_OK:
- newproj = dlg.GetValue()
- dlg.Destroy()
- dlg = wxFileDialog (self, "Place to store new project", ".", "", "*.wxp",
- wxSAVE)
- if dlg.ShowModal() == wxID_OK:
- try:
- proj = open (dlg.GetPath(), 'w')
- proj.write (newproj + "\n")
- proj.close()
- self.project_open (dlg.GetPath())
- except IOError:
- dlg_m = wxMessageDialog (self,
- 'There was an error saving the new project file.',
- 'Error!', wxOK)
- dlg_m.ShowModal()
- dlg_m.Destroy()
- dlg.Destroy()
+ dlg = wx.TextEntryDialog(self, 'Name for new project:', 'New Project',
+ 'New project', wx.OK|wx.CANCEL)
+ if dlg.ShowModal() == wx.ID_OK:
+ newproj = dlg.GetValue()
+ dlg.Destroy()
+ dlg = wx.FileDialog(self, 'Place to store new project.', '.', '', '*.wxp', wx.SAVE)
+ if dlg.ShowModal() == wx.ID_OK:
+ try:
+ # save the project file.
+ proj = open(dlg.GetPath(), 'w')
+ proj.write(newproj + '\n')
+ proj.close()
+ self.project_open(dlg.GetPath())
+ except IOError:
+ MsgDlg(self, 'There was an error saving the new project file.', 'Error!', wx.OK)
+ dlg.Destroy()
+
+ def SaveCurrentFile(self):
+ """Check and save current file."""
+ go_ahead = True
+ if self.root:
+ if self.activeitem != self.root:
+ if self.editor.IsModified(): # Save modified file before
+ result = MsgDlg(self, 'The edited file has changed. Save it?')
+ if result == wx.ID_YES:
+ self.editor.SaveFile(self.tree.GetItemText(self.activeitem))
+ if result == wx.ID_CANCEL:
+ go_ahead = False
+ if go_ahead:
+ self.tree.SetItemBold(self.activeitem, 0)
+ return go_ahead