chiark / gitweb /
Update the doodle3d class to auto-detect local network boxes, as well as access point...
[cura.git] / Cura / gui / alterationPanel.py
1 from __future__ import absolute_import
2 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
3
4 import wx, wx.stc
5
6 from Cura.gui.util import gcodeTextArea
7 from Cura.util import profile
8 #Panel to change the start & endcode of the gcode.
9 class alterationPanel(wx.Panel):
10         def __init__(self, parent, callback):
11                 wx.Panel.__init__(self, parent,-1)
12
13                 self.callback = callback
14                 self.alterationFileList = ['start.gcode', 'end.gcode']#, 'nextobject.gcode', 'replace.csv'
15                 if int(profile.getMachineSetting('extruder_amount')) > 1:
16                         self.alterationFileList += ['start2.gcode', 'end2.gcode']
17                 self.currentFile = None
18
19                 self.textArea = gcodeTextArea.GcodeTextArea(self)
20                 self.list = wx.ListBox(self, choices=self.alterationFileList, style=wx.LB_SINGLE)
21                 self.list.SetSelection(0)
22                 self.Bind(wx.EVT_LISTBOX, self.OnSelect, self.list)
23                 self.textArea.Bind(wx.EVT_KILL_FOCUS, self.OnFocusLost, self.textArea)
24                 self.textArea.Bind(wx.stc.EVT_STC_CHANGE, self.OnFocusLost, self.textArea)
25                 
26                 sizer = wx.GridBagSizer()
27                 sizer.Add(self.list, (0,0), span=(5,1), flag=wx.EXPAND)
28                 sizer.Add(self.textArea, (5,0), span=(5,1), flag=wx.EXPAND)
29                 sizer.AddGrowableCol(0)
30                 sizer.AddGrowableRow(0)
31                 sizer.AddGrowableRow(5)
32                 sizer.AddGrowableRow(6)
33                 sizer.AddGrowableRow(7)
34                 self.SetSizer(sizer)
35                 
36                 self.loadFile(self.alterationFileList[self.list.GetSelection()])
37                 self.currentFile = self.list.GetSelection()
38
39         def OnSelect(self, e):
40                 self.loadFile(self.alterationFileList[self.list.GetSelection()])
41                 self.currentFile = self.list.GetSelection()
42
43         def loadFile(self, filename):
44                 self.textArea.SetValue(profile.getAlterationFile(filename))
45
46         def OnFocusLost(self, e):
47                 if self.currentFile == self.list.GetSelection():
48                         profile.setAlterationFile(self.alterationFileList[self.list.GetSelection()], self.textArea.GetValue())
49                         self.callback()
50
51         def updateProfileToControls(self):
52                 self.OnSelect(None)