2012-02-21 22:05:30 +00:00
|
|
|
import wx
|
2012-02-22 19:44:00 +00:00
|
|
|
import sys,math,threading,os
|
2012-02-21 22:05:30 +00:00
|
|
|
|
2012-03-27 15:20:30 +00:00
|
|
|
from gui import profile
|
2012-02-21 22:05:30 +00:00
|
|
|
|
|
|
|
class alterationPanel(wx.Panel):
|
|
|
|
def __init__(self, parent):
|
|
|
|
wx.Panel.__init__(self, parent,-1)
|
|
|
|
|
2012-03-27 11:48:40 +00:00
|
|
|
self.alterationFileList = ['start.gcode', 'end.gcode', 'cool_start.gcode', 'cool_end.gcode', 'replace.csv']
|
2012-03-09 16:00:09 +00:00
|
|
|
self.currentFile = None
|
2012-02-21 22:05:30 +00:00
|
|
|
|
2012-02-22 19:44:00 +00:00
|
|
|
self.textArea = wx.TextCtrl(self, style=wx.TE_MULTILINE|wx.TE_DONTWRAP|wx.TE_PROCESS_TAB)
|
2012-03-09 16:02:30 +00:00
|
|
|
self.textArea.SetFont(wx.Font(wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize(), wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
|
2012-02-21 22:05:30 +00:00
|
|
|
self.list = wx.ListBox(self, choices=self.alterationFileList, style=wx.LB_SINGLE)
|
|
|
|
self.list.SetSelection(0)
|
|
|
|
self.Bind(wx.EVT_LISTBOX, self.OnSelect, self.list)
|
2012-02-22 19:44:00 +00:00
|
|
|
self.textArea.Bind(wx.EVT_KILL_FOCUS, self.OnFocusLost, self.textArea)
|
2012-02-21 22:05:30 +00:00
|
|
|
|
|
|
|
sizer = wx.GridBagSizer()
|
|
|
|
sizer.Add(self.list, (0,0), span=(1,1), flag=wx.EXPAND)
|
|
|
|
sizer.Add(self.textArea, (0,1), span=(1,1), flag=wx.EXPAND)
|
|
|
|
sizer.AddGrowableCol(1)
|
|
|
|
sizer.AddGrowableRow(0)
|
|
|
|
self.SetSizer(sizer)
|
2012-02-22 19:44:00 +00:00
|
|
|
|
|
|
|
self.loadFile(self.alterationFileList[self.list.GetSelection()])
|
2012-02-21 22:05:30 +00:00
|
|
|
|
|
|
|
def OnSelect(self, e):
|
|
|
|
self.loadFile(self.alterationFileList[self.list.GetSelection()])
|
2012-03-09 16:00:09 +00:00
|
|
|
self.currentFile = self.list.GetSelection()
|
2012-02-21 22:05:30 +00:00
|
|
|
|
|
|
|
def loadFile(self, filename):
|
2012-03-27 11:48:40 +00:00
|
|
|
self.textArea.SetValue(unicode(profile.getAlterationFileContents(filename, False), "utf-8"))
|
2012-02-22 19:44:00 +00:00
|
|
|
|
|
|
|
def OnFocusLost(self, e):
|
2012-03-09 16:00:09 +00:00
|
|
|
if self.currentFile == self.list.GetSelection():
|
2012-03-27 11:48:40 +00:00
|
|
|
filename = profile.getAlterationFilePath(self.alterationFileList[self.list.GetSelection()])
|
2012-03-09 16:00:09 +00:00
|
|
|
f = open(filename, "wb")
|
2012-03-09 16:12:18 +00:00
|
|
|
f.write(self.textArea.GetValue().encode("utf-8"))
|
2012-03-09 16:00:09 +00:00
|
|
|
f.close()
|