2 import sys,math,threading,os
\r
4 from util import profile
\r
6 class alterationPanel(wx.Panel):
\r
7 def __init__(self, parent):
\r
8 wx.Panel.__init__(self, parent,-1)
\r
10 self.alterationFileList = ['start.gcode', 'end.gcode', 'cool_start.gcode', 'cool_end.gcode', 'replace.csv']
\r
11 self.currentFile = None
\r
13 self.textArea = wx.TextCtrl(self, style=wx.TE_MULTILINE|wx.TE_DONTWRAP|wx.TE_PROCESS_TAB)
\r
14 self.textArea.SetFont(wx.Font(wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize(), wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
\r
15 self.list = wx.ListBox(self, choices=self.alterationFileList, style=wx.LB_SINGLE)
\r
16 self.list.SetSelection(0)
\r
17 self.Bind(wx.EVT_LISTBOX, self.OnSelect, self.list)
\r
18 self.textArea.Bind(wx.EVT_KILL_FOCUS, self.OnFocusLost, self.textArea)
\r
20 sizer = wx.GridBagSizer()
\r
21 sizer.Add(self.list, (0,0), span=(1,1), flag=wx.EXPAND)
\r
22 sizer.Add(self.textArea, (0,1), span=(1,1), flag=wx.EXPAND)
\r
23 sizer.AddGrowableCol(1)
\r
24 sizer.AddGrowableRow(0)
\r
25 self.SetSizer(sizer)
\r
27 self.loadFile(self.alterationFileList[self.list.GetSelection()])
\r
29 def OnSelect(self, e):
\r
30 self.loadFile(self.alterationFileList[self.list.GetSelection()])
\r
31 self.currentFile = self.list.GetSelection()
\r
33 def loadFile(self, filename):
\r
34 self.textArea.SetValue(unicode(profile.getAlterationFileContents(filename, False), "utf-8"))
\r
36 def OnFocusLost(self, e):
\r
37 if self.currentFile == self.list.GetSelection():
\r
38 filename = profile.getAlterationFilePath(self.alterationFileList[self.list.GetSelection()])
\r
39 f = open(filename, "wb")
\r
40 f.write(self.textArea.GetValue().encode("utf-8"))
\r