2012-05-11 00:31:18 +00:00
|
|
|
import wx,wx.stc
|
2012-02-22 19:44:00 +00:00
|
|
|
import sys,math,threading,os
|
2012-02-21 22:05:30 +00:00
|
|
|
|
2012-05-02 15:54:29 +00:00
|
|
|
from gui import gcodeTextArea
|
2012-03-28 12:26:40 +00:00
|
|
|
from util 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-04-24 10:03:03 +00:00
|
|
|
self.alterationFileList = ['start.gcode', 'end.gcode', 'support_start.gcode', 'support_end.gcode', 'nextobject.gcode', 'replace.csv']
|
2012-05-07 15:42:46 +00:00
|
|
|
if int(profile.getPreference('extruder_amount')) > 1:
|
|
|
|
self.alterationFileList.append('switchExtruder.gcode')
|
2012-03-09 16:00:09 +00:00
|
|
|
self.currentFile = None
|
2012-02-21 22:05:30 +00:00
|
|
|
|
2012-05-02 15:15:55 +00:00
|
|
|
#self.textArea = wx.TextCtrl(self, style=wx.TE_MULTILINE|wx.TE_DONTWRAP|wx.TE_PROCESS_TAB)
|
|
|
|
#self.textArea.SetFont(wx.Font(wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize(), wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
|
2012-05-02 15:54:29 +00:00
|
|
|
self.textArea = gcodeTextArea.GcodeTextArea(self)
|
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-05-11 00:31:18 +00:00
|
|
|
self.textArea.Bind(wx.stc.EVT_STC_CHANGE, 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-03-30 07:49:28 +00:00
|
|
|
self.currentFile = 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-05-02 15:54:29 +00:00
|
|
|
self.textArea.SetValue(profile.getAlterationFile(filename))
|
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-05-02 15:54:29 +00:00
|
|
|
profile.setAlterationFile(self.alterationFileList[self.list.GetSelection()], self.textArea.GetValue())
|
2012-04-23 16:02:30 +00:00
|
|
|
|
2012-07-25 08:41:05 +00:00
|
|
|
def updateProfileToControls(self):
|
|
|
|
self.OnSelect(None)
|
|
|
|
|