import wx from service.fit import Fit import gui.mainFrame from gui import globalEvents as GE from .calcCommands.shipModeChange import CalcChangeShipModeCommand class GuiSetModeCommand(wx.Command): def __init__(self, fitID, itemID): wx.Command.__init__(self, True, "Mode Set") self.internalHistory = wx.CommandProcessor() self.fitID = fitID self.itemID = itemID def Do(self): if self.internalHistory.Submit(CalcChangeShipModeCommand(self.fitID, self.itemID)): Fit.getInstance().recalc(self.fitID) wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True return False def Undo(self): for _ in self.internalHistory.Commands: self.internalHistory.Undo() Fit.getInstance().recalc(self.fitID) wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID)) return True