diff --git a/gui/mainFrame.py b/gui/mainFrame.py index 0c5a6e268..76349e7fd 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -334,9 +334,15 @@ class MainFrame(wx.Frame): filePath = saveDialog.GetPath() if '.' not in os.path.basename(filePath): filePath += ".xml" - sFit.backupFits(filePath ) + self.waitDialog = WaitDialog(self) + sFit.backupFits(filePath, self.closeWaitDialog) + self.waitDialog.ShowModal() + saveDialog.Destroy() + def closeWaitDialog(self): + self.waitDialog.Destroy() + def toggleShipBrowser(self, event): self.GetToolBar().toggleShipBrowser(event) @@ -352,3 +358,9 @@ class MainFrame(wx.Frame): wnd = self InspectionTool().Show(wnd, True) +class WaitDialog(wx.Dialog): + def __init__(self, parent): + wx.Dialog.__init__ (self, parent, id=wx.ID_ANY, title=u"Please wait ...", size=wx.Size(200, 100), + style=wx.DEFAULT_FRAME_STYLE | wx.FRAME_FLOAT_ON_PARENT | wx.TAB_TRAVERSAL) + + wx.StaticText(self, wx.ID_ANY, "Please wait ...") diff --git a/service/fit.py b/service/fit.py index fcd45208e..09a8586a3 100644 --- a/service/fit.py +++ b/service/fit.py @@ -23,6 +23,24 @@ from eos.types import State, Slot import copy from service.damagePattern import DamagePattern from service.character import Character +import threading +import wx + +class FitBackupThread(threading.Thread): + def __init__(self, path, callback): + threading.Thread.__init__(self) + self.path = path + self.callback = callback + + def run(self): + path = self.path + sFit = Fit.getInstance() + allFits = map(lambda x: x[0], sFit.getAllFits()) + backedUpFits = sFit.exportXml(*allFits) + backupFile = open(path, "w") + backupFile.write(backedUpFits) + backupFile.close() + wx.CallAfter(self.callback) class Fit(object): instance = None @@ -45,7 +63,6 @@ class Fit(object): return names - def getFitsWithShip(self, id): fits = eos.db.getFitsWithShip(id) names = [] @@ -469,12 +486,9 @@ class Fit(object): fits = map(lambda id: eos.db.getFit(id), fitIDs) return eos.types.Fit.exportXml(*fits) - def backupFits(self, path): - allFits = map(lambda x: x[0], self.getAllFits()) - backedUpFits = self.exportXml(*allFits) - backupFile = open(path, "w") - backupFile.write(backedUpFits) - backupFile.close() + def backupFits(self, path, callback): + thread = FitBackupThread(path, callback) + thread.start() def importFit(self, path): f = file(path)