Only save the alteration file if it was loaded

master
Daid 2012-03-09 17:00:09 +01:00
parent d1203aa101
commit 425dcaae75
2 changed files with 8 additions and 5 deletions

View File

@ -9,6 +9,7 @@ class alterationPanel(wx.Panel):
wx.Panel.__init__(self, parent,-1)
self.alterationFileList = ['start.gcode', 'end.gcode', 'cool_start.gcode', 'cool_end.gcode']
self.currentFile = None
self.textArea = wx.TextCtrl(self, style=wx.TE_MULTILINE|wx.TE_DONTWRAP|wx.TE_PROCESS_TAB)
self.textArea.SetFont(wx.Font(8, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
@ -28,12 +29,14 @@ class alterationPanel(wx.Panel):
def OnSelect(self, e):
self.loadFile(self.alterationFileList[self.list.GetSelection()])
self.currentFile = self.list.GetSelection()
def loadFile(self, filename):
self.textArea.SetValue(settings.getAlterationFile(filename, False))
def OnFocusLost(self, e):
filename = os.path.join(archive.getSkeinforgePath('alterations'), self.alterationFileList[self.list.GetSelection()])
f = open(filename, "wb")
f.write(self.textArea.GetValue())
f.close()
if self.currentFile == self.list.GetSelection():
filename = os.path.join(archive.getSkeinforgePath('alterations'), self.alterationFileList[self.list.GetSelection()])
f = open(filename, "wb")
f.write(self.textArea.GetValue())
f.close()

View File

@ -47,7 +47,7 @@ class previewPanel(wx.Panel):
self.transparentButton = wx.Button(self.toolbar, -1, "T", size=(21,21))
self.toolbar.AddControl(self.transparentButton)
self.Bind(wx.EVT_BUTTON, self.OnTransparentClick, self.transparentButton)
self.depthComplexityButton = wx.Button(self.toolbar, -1, "DC", size=(21*2,21))
self.depthComplexityButton = wx.Button(self.toolbar, -1, "X-RAY", size=(21*2,21))
self.toolbar.AddControl(self.depthComplexityButton)
self.Bind(wx.EVT_BUTTON, self.OnDepthComplexityClick, self.depthComplexityButton)