1 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
5 from Cura.gui.util import gcodeTextArea
6 from Cura.util import profile
7 #Panel to change the start & endcode of the gcode.
8 class alterationPanel(wx.Panel):
9 def __init__(self, parent, callback):
10 wx.Panel.__init__(self, parent,-1)
12 self.callback = callback
13 self.alterationFileList = ['start.gcode', 'end.gcode']#, 'nextobject.gcode', 'replace.csv'
14 if int(profile.getMachineSetting('extruder_amount')) > 1:
15 self.alterationFileList += ['preSwitchExtruder.gcode', 'postSwitchExtruder.gcode']
16 self.alterationFileList += ['start2.gcode', 'end2.gcode']
17 if int(profile.getMachineSetting('extruder_amount')) > 2:
18 self.alterationFileList += ['start3.gcode', 'end3.gcode']
19 if int(profile.getMachineSetting('extruder_amount')) > 3:
20 self.alterationFileList += ['start4.gcode', 'end4.gcode']
21 if int(profile.getMachineSetting('extruder_amount')) > 4:
22 self.alterationFileList += ['start5.gcode', 'end5.gcode']
23 self.currentFile = None
25 self.textArea = gcodeTextArea.GcodeTextArea(self)
26 self.list = wx.ListBox(self, choices=self.alterationFileList, style=wx.LB_SINGLE)
27 self.list.SetSelection(0)
28 self.Bind(wx.EVT_LISTBOX, self.OnSelect, self.list)
29 self.textArea.Bind(wx.EVT_KILL_FOCUS, self.OnFocusLost, self.textArea)
30 self.textArea.Bind(wx.stc.EVT_STC_CHANGE, self.OnFocusLost, self.textArea)
32 sizer = wx.GridBagSizer()
33 sizer.Add(self.list, (0,0), span=(5,1), flag=wx.EXPAND)
34 sizer.Add(self.textArea, (5,0), span=(5,1), flag=wx.EXPAND)
35 sizer.AddGrowableCol(0)
36 sizer.AddGrowableRow(0)
37 sizer.AddGrowableRow(5)
38 sizer.AddGrowableRow(6)
39 sizer.AddGrowableRow(7)
42 self.loadFile(self.alterationFileList[self.list.GetSelection()])
43 self.currentFile = self.list.GetSelection()
45 def OnSelect(self, e):
46 self.loadFile(self.alterationFileList[self.list.GetSelection()])
47 self.currentFile = self.list.GetSelection()
49 def loadFile(self, filename):
50 self.textArea.SetValue(profile.getAlterationFile(filename))
52 def OnFocusLost(self, e):
53 if self.currentFile == self.list.GetSelection():
54 profile.setAlterationFile(self.alterationFileList[self.list.GetSelection()], self.textArea.GetValue())
57 def updateProfileToControls(self):