Fri, 03 Jun 2016 10:05:45 +0200
remove pyc files
15 | 1 | # This file is part of the Printrun suite. |
2 | # | |
3 | # Printrun is free software: you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation, either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # Printrun is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with Printrun. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | import wx | |
17 | ||
18 | from .xybuttons import XYButtons, XYButtonsMini | |
19 | from .zbuttons import ZButtons, ZButtonsMini | |
20 | from .graph import Graph | |
21 | from .widgets import TempGauge | |
22 | from wx.lib.agw.floatspin import FloatSpin | |
23 | ||
24 | from .utils import make_button, make_custom_button | |
25 | ||
26 | class XYZControlsSizer(wx.GridBagSizer): | |
27 | ||
28 | def __init__(self, root, parentpanel = None): | |
29 | super(XYZControlsSizer, self).__init__() | |
30 | if not parentpanel: parentpanel = root.panel | |
31 | root.xyb = XYButtons(parentpanel, root.moveXY, root.homeButtonClicked, root.spacebarAction, root.bgcolor, zcallback=root.moveZ) | |
32 | self.Add(root.xyb, pos = (0, 1), flag = wx.ALIGN_CENTER) | |
33 | root.zb = ZButtons(parentpanel, root.moveZ, root.bgcolor) | |
34 | self.Add(root.zb, pos = (0, 2), flag = wx.ALIGN_CENTER) | |
35 | wx.CallAfter(root.xyb.SetFocus) | |
36 | ||
37 | def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode = False): | |
38 | standalone_mode = extra_buttons is not None | |
39 | base_line = 1 if standalone_mode else 2 | |
40 | ||
41 | if standalone_mode: | |
42 | gauges_base_line = base_line + 10 | |
43 | elif mini_mode and root.display_graph: | |
44 | gauges_base_line = base_line + 7 | |
45 | else: | |
46 | gauges_base_line = base_line + 6 | |
47 | tempdisp_line = gauges_base_line + (2 if root.display_gauges else 0) | |
48 | if mini_mode and root.display_graph: | |
49 | e_base_line = base_line + 3 | |
50 | else: | |
51 | e_base_line = base_line + 2 | |
52 | ||
53 | pos_mapping = { | |
54 | "htemp_label": (base_line + 0, 0), | |
55 | "htemp_off": (base_line + 0, 2), | |
56 | "htemp_val": (base_line + 0, 3), | |
57 | "htemp_set": (base_line + 0, 4), | |
58 | "btemp_label": (base_line + 1, 0), | |
59 | "btemp_off": (base_line + 1, 2), | |
60 | "btemp_val": (base_line + 1, 3), | |
61 | "btemp_set": (base_line + 1, 4), | |
62 | "ebuttons": (e_base_line + 0, 0), | |
63 | "esettings": (e_base_line + 1, 0), | |
64 | "speedcontrol": (e_base_line + 2, 0), | |
65 | "flowcontrol": (e_base_line + 3, 0), | |
66 | "htemp_gauge": (gauges_base_line + 0, 0), | |
67 | "btemp_gauge": (gauges_base_line + 1, 0), | |
68 | "tempdisp": (tempdisp_line, 0), | |
69 | "extrude": (3, 0), | |
70 | "reverse": (3, 2), | |
71 | } | |
72 | ||
73 | span_mapping = { | |
74 | "htemp_label": (1, 2), | |
75 | "htemp_off": (1, 1), | |
76 | "htemp_val": (1, 1), | |
77 | "htemp_set": (1, 1 if root.display_graph else 2), | |
78 | "btemp_label": (1, 2), | |
79 | "btemp_off": (1, 1), | |
80 | "btemp_val": (1, 1), | |
81 | "btemp_set": (1, 1 if root.display_graph else 2), | |
82 | "ebuttons": (1, 5 if root.display_graph else 6), | |
83 | "esettings": (1, 5 if root.display_graph else 6), | |
84 | "speedcontrol": (1, 5 if root.display_graph else 6), | |
85 | "flowcontrol": (1, 5 if root.display_graph else 6), | |
86 | "htemp_gauge": (1, 5 if mini_mode else 6), | |
87 | "btemp_gauge": (1, 5 if mini_mode else 6), | |
88 | "tempdisp": (1, 5 if mini_mode else 6), | |
89 | "extrude": (1, 2), | |
90 | "reverse": (1, 3), | |
91 | } | |
92 | ||
93 | if standalone_mode: | |
94 | pos_mapping["tempgraph"] = (base_line + 5, 0) | |
95 | span_mapping["tempgraph"] = (5, 6) | |
96 | elif mini_mode: | |
97 | pos_mapping["tempgraph"] = (base_line + 2, 0) | |
98 | span_mapping["tempgraph"] = (1, 5) | |
99 | else: | |
100 | pos_mapping["tempgraph"] = (base_line + 0, 5) | |
101 | span_mapping["tempgraph"] = (5, 1) | |
102 | ||
103 | if mini_mode: | |
104 | pos_mapping["etool_label"] = (0, 0) | |
105 | pos_mapping["etool_val"] = (0, 1) | |
106 | pos_mapping["edist_label"] = (0, 2) | |
107 | pos_mapping["edist_val"] = (0, 3) | |
108 | pos_mapping["edist_unit"] = (0, 4) | |
109 | else: | |
110 | pos_mapping["edist_label"] = (0, 0) | |
111 | pos_mapping["edist_val"] = (1, 0) | |
112 | pos_mapping["edist_unit"] = (1, 1) | |
113 | pos_mapping["efeed_label"] = (0, 2) | |
114 | pos_mapping["efeed_val"] = (1, 2) | |
115 | pos_mapping["efeed_unit"] = (1, 3) | |
116 | ||
117 | def add(name, widget, *args, **kwargs): | |
118 | kwargs["pos"] = pos_mapping[name] | |
119 | if name in span_mapping: | |
120 | kwargs["span"] = span_mapping[name] | |
121 | if "container" in kwargs: | |
122 | container = kwargs["container"] | |
123 | del kwargs["container"] | |
124 | else: | |
125 | container = self | |
126 | container.Add(widget, *args, **kwargs) | |
127 | ||
128 | # Hotend & bed temperatures # | |
129 | ||
130 | # Hotend temp | |
131 | add("htemp_label", wx.StaticText(parentpanel, -1, _("Heat:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) | |
132 | htemp_choices = [root.temps[i] + " (" + i + ")" for i in sorted(root.temps.keys(), key = lambda x:root.temps[x])] | |
133 | ||
134 | root.settoff = make_button(parentpanel, _("Off"), lambda e: root.do_settemp("off"), _("Switch Hotend Off"), size = (38, -1), style = wx.BU_EXACTFIT) | |
135 | root.printerControls.append(root.settoff) | |
136 | add("htemp_off", root.settoff) | |
137 | ||
138 | if root.settings.last_temperature not in map(float, root.temps.values()): | |
139 | htemp_choices = [str(root.settings.last_temperature)] + htemp_choices | |
140 | root.htemp = wx.ComboBox(parentpanel, -1, choices = htemp_choices, | |
141 | style = wx.CB_DROPDOWN, size = (80, -1)) | |
142 | root.htemp.SetToolTip(wx.ToolTip(_("Select Temperature for Hotend"))) | |
143 | root.htemp.Bind(wx.EVT_COMBOBOX, root.htemp_change) | |
144 | ||
145 | add("htemp_val", root.htemp) | |
146 | root.settbtn = make_button(parentpanel, _("Set"), root.do_settemp, _("Switch Hotend On"), size = (38, -1), style = wx.BU_EXACTFIT) | |
147 | root.printerControls.append(root.settbtn) | |
148 | add("htemp_set", root.settbtn, flag = wx.EXPAND) | |
149 | ||
150 | # Bed temp | |
151 | add("btemp_label", wx.StaticText(parentpanel, -1, _("Bed:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) | |
152 | btemp_choices = [root.bedtemps[i] + " (" + i + ")" for i in sorted(root.bedtemps.keys(), key = lambda x:root.temps[x])] | |
153 | ||
154 | root.setboff = make_button(parentpanel, _("Off"), lambda e: root.do_bedtemp("off"), _("Switch Heated Bed Off"), size = (38, -1), style = wx.BU_EXACTFIT) | |
155 | root.printerControls.append(root.setboff) | |
156 | add("btemp_off", root.setboff) | |
157 | ||
158 | if root.settings.last_bed_temperature not in map(float, root.bedtemps.values()): | |
159 | btemp_choices = [str(root.settings.last_bed_temperature)] + btemp_choices | |
160 | root.btemp = wx.ComboBox(parentpanel, -1, choices = btemp_choices, | |
161 | style = wx.CB_DROPDOWN, size = (80, -1)) | |
162 | root.btemp.SetToolTip(wx.ToolTip(_("Select Temperature for Heated Bed"))) | |
163 | root.btemp.Bind(wx.EVT_COMBOBOX, root.btemp_change) | |
164 | add("btemp_val", root.btemp) | |
165 | ||
166 | root.setbbtn = make_button(parentpanel, _("Set"), root.do_bedtemp, _("Switch Heated Bed On"), size = (38, -1), style = wx.BU_EXACTFIT) | |
167 | root.printerControls.append(root.setbbtn) | |
168 | add("btemp_set", root.setbbtn, flag = wx.EXPAND) | |
169 | ||
170 | root.btemp.SetValue(str(root.settings.last_bed_temperature)) | |
171 | root.htemp.SetValue(str(root.settings.last_temperature)) | |
172 | ||
173 | # added for an error where only the bed would get (pla) or (abs). | |
174 | # This ensures, if last temp is a default pla or abs, it will be marked so. | |
175 | # if it is not, then a (user) remark is added. This denotes a manual entry | |
176 | ||
177 | for i in btemp_choices: | |
178 | if i.split()[0] == str(root.settings.last_bed_temperature).split('.')[0] or i.split()[0] == str(root.settings.last_bed_temperature): | |
179 | root.btemp.SetValue(i) | |
180 | for i in htemp_choices: | |
181 | if i.split()[0] == str(root.settings.last_temperature).split('.')[0] or i.split()[0] == str(root.settings.last_temperature): | |
182 | root.htemp.SetValue(i) | |
183 | ||
184 | if '(' not in root.btemp.Value: | |
185 | root.btemp.SetValue(root.btemp.Value + ' (user)') | |
186 | if '(' not in root.htemp.Value: | |
187 | root.htemp.SetValue(root.htemp.Value + ' (user)') | |
188 | ||
189 | # Speed control # | |
190 | speedpanel = root.newPanel(parentpanel) | |
191 | speedsizer = wx.BoxSizer(wx.HORIZONTAL) | |
192 | speedsizer.Add(wx.StaticText(speedpanel, -1, _("Print speed:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) | |
193 | ||
194 | root.speed_slider = wx.Slider(speedpanel, -1, 100, 1, 300) | |
195 | speedsizer.Add(root.speed_slider, 1, flag = wx.EXPAND) | |
196 | ||
197 | root.speed_spin = FloatSpin(speedpanel, -1, value = 100, min_val = 1, max_val = 300, digits = 0, style = wx.ALIGN_LEFT, size = (80, -1)) | |
198 | speedsizer.Add(root.speed_spin, 0, flag = wx.ALIGN_CENTER_VERTICAL) | |
199 | root.speed_label = wx.StaticText(speedpanel, -1, _("%")) | |
200 | speedsizer.Add(root.speed_label, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) | |
201 | ||
202 | def speedslider_set(event): | |
203 | root.do_setspeed() | |
204 | root.speed_setbtn.SetBackgroundColour(wx.NullColour) | |
205 | root.speed_setbtn = make_button(speedpanel, _("Set"), speedslider_set, _("Set print speed factor"), size = (38, -1), style = wx.BU_EXACTFIT) | |
206 | root.printerControls.append(root.speed_setbtn) | |
207 | speedsizer.Add(root.speed_setbtn, flag = wx.ALIGN_CENTER) | |
208 | speedpanel.SetSizer(speedsizer) | |
209 | add("speedcontrol", speedpanel, flag = wx.EXPAND) | |
210 | ||
211 | def speedslider_spin(event): | |
212 | value = root.speed_spin.GetValue() | |
213 | root.speed_setbtn.SetBackgroundColour("red") | |
214 | root.speed_slider.SetValue(value) | |
215 | root.speed_spin.Bind(wx.EVT_SPINCTRL, speedslider_spin) | |
216 | ||
217 | def speedslider_scroll(event): | |
218 | value = root.speed_slider.GetValue() | |
219 | root.speed_setbtn.SetBackgroundColour("red") | |
220 | root.speed_spin.SetValue(value) | |
221 | root.speed_slider.Bind(wx.EVT_SCROLL, speedslider_scroll) | |
222 | ||
223 | # Flow control # | |
224 | flowpanel = root.newPanel(parentpanel) | |
225 | flowsizer = wx.BoxSizer(wx.HORIZONTAL) | |
226 | flowsizer.Add(wx.StaticText(flowpanel, -1, _("Print flow:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) | |
227 | ||
228 | root.flow_slider = wx.Slider(flowpanel, -1, 100, 1, 300) | |
229 | flowsizer.Add(root.flow_slider, 1, flag = wx.EXPAND) | |
230 | ||
231 | root.flow_spin = FloatSpin(flowpanel, -1, value = 100, min_val = 1, max_val = 300, digits = 0, style = wx.ALIGN_LEFT, size = (60, -1)) | |
232 | flowsizer.Add(root.flow_spin, 0, flag = wx.ALIGN_CENTER_VERTICAL) | |
233 | root.flow_label = wx.StaticText(flowpanel, -1, _("%")) | |
234 | flowsizer.Add(root.flow_label, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) | |
235 | ||
236 | def flowslider_set(event): | |
237 | root.do_setflow() | |
238 | root.flow_setbtn.SetBackgroundColour(wx.NullColour) | |
239 | root.flow_setbtn = make_button(flowpanel, _("Set"), flowslider_set, _("Set print flow factor"), size = (38, -1), style = wx.BU_EXACTFIT) | |
240 | root.printerControls.append(root.flow_setbtn) | |
241 | flowsizer.Add(root.flow_setbtn, flag = wx.ALIGN_CENTER) | |
242 | flowpanel.SetSizer(flowsizer) | |
243 | add("flowcontrol", flowpanel, flag = wx.EXPAND) | |
244 | ||
245 | def flowslider_spin(event): | |
246 | value = root.flow_spin.GetValue() | |
247 | root.flow_setbtn.SetBackgroundColour("red") | |
248 | root.flow_slider.SetValue(value) | |
249 | root.flow_spin.Bind(wx.EVT_SPINCTRL, flowslider_spin) | |
250 | ||
251 | def flowslider_scroll(event): | |
252 | value = root.flow_slider.GetValue() | |
253 | root.flow_setbtn.SetBackgroundColour("red") | |
254 | root.flow_spin.SetValue(value) | |
255 | root.flow_slider.Bind(wx.EVT_SCROLL, flowslider_scroll) | |
256 | ||
257 | # Temperature gauges # | |
258 | ||
259 | if root.display_gauges: | |
260 | root.hottgauge = TempGauge(parentpanel, size = (-1, 24), title = _("Heater:"), maxval = 300, bgcolor = root.bgcolor) | |
261 | add("htemp_gauge", root.hottgauge, flag = wx.EXPAND) | |
262 | root.bedtgauge = TempGauge(parentpanel, size = (-1, 24), title = _("Bed:"), maxval = 150, bgcolor = root.bgcolor) | |
263 | add("btemp_gauge", root.bedtgauge, flag = wx.EXPAND) | |
264 | ||
265 | def hotendgauge_scroll_setpoint(e): | |
266 | rot = e.GetWheelRotation() | |
267 | if rot > 0: | |
268 | root.do_settemp(str(root.hsetpoint + 1)) | |
269 | elif rot < 0: | |
270 | root.do_settemp(str(max(0, root.hsetpoint - 1))) | |
271 | ||
272 | def bedgauge_scroll_setpoint(e): | |
273 | rot = e.GetWheelRotation() | |
274 | if rot > 0: | |
275 | root.do_settemp(str(root.bsetpoint + 1)) | |
276 | elif rot < 0: | |
277 | root.do_settemp(str(max(0, root.bsetpoint - 1))) | |
278 | root.hottgauge.Bind(wx.EVT_MOUSEWHEEL, hotendgauge_scroll_setpoint) | |
279 | root.bedtgauge.Bind(wx.EVT_MOUSEWHEEL, bedgauge_scroll_setpoint) | |
280 | ||
281 | # Temperature (M105) feedback display # | |
282 | root.tempdisp = wx.StaticText(parentpanel, -1, "", style = wx.ST_NO_AUTORESIZE) | |
283 | ||
284 | def on_tempdisp_size(evt): | |
285 | root.tempdisp.Wrap(root.tempdisp.GetSize().width) | |
286 | root.tempdisp.Bind(wx.EVT_SIZE, on_tempdisp_size) | |
287 | ||
288 | def tempdisp_setlabel(label): | |
289 | wx.StaticText.SetLabel(root.tempdisp, label) | |
290 | root.tempdisp.Wrap(root.tempdisp.GetSize().width) | |
291 | root.tempdisp.SetSize((-1, root.tempdisp.GetBestSize().height)) | |
292 | root.tempdisp.SetLabel = tempdisp_setlabel | |
293 | add("tempdisp", root.tempdisp, flag = wx.EXPAND) | |
294 | ||
295 | # Temperature graph # | |
296 | ||
297 | if root.display_graph: | |
298 | root.graph = Graph(parentpanel, wx.ID_ANY, root) | |
299 | add("tempgraph", root.graph, flag = wx.EXPAND | wx.ALL, border = 5) | |
300 | root.graph.Bind(wx.EVT_LEFT_DOWN, root.graph.show_graph_window) | |
301 | ||
302 | # Extrusion controls # | |
303 | ||
304 | # Extrusion settings | |
305 | esettingspanel = root.newPanel(parentpanel) | |
306 | esettingssizer = wx.GridBagSizer() | |
307 | esettingssizer.SetEmptyCellSize((0, 0)) | |
308 | root.edist = FloatSpin(esettingspanel, -1, value = root.settings.last_extrusion, min_val = 0, max_val = 1000, size = (90, -1), digits = 1) | |
309 | root.edist.SetBackgroundColour((225, 200, 200)) | |
310 | root.edist.SetForegroundColour("black") | |
311 | root.edist.Bind(wx.EVT_SPINCTRL, root.setfeeds) | |
312 | root.edist.Bind(wx.EVT_TEXT, root.setfeeds) | |
313 | add("edist_label", wx.StaticText(esettingspanel, -1, _("Length:")), container = esettingssizer, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.RIGHT | wx.LEFT, border = 5) | |
314 | add("edist_val", root.edist, container = esettingssizer, flag = wx.ALIGN_CENTER | wx.RIGHT, border = 5) | |
315 | unit_label = _("mm") if mini_mode else _("mm @") | |
316 | add("edist_unit", wx.StaticText(esettingspanel, -1, unit_label), container = esettingssizer, flag = wx.ALIGN_CENTER | wx.RIGHT, border = 5) | |
317 | root.edist.SetToolTip(wx.ToolTip(_("Amount to Extrude or Retract (mm)"))) | |
318 | if not mini_mode: | |
319 | root.efeedc = FloatSpin(esettingspanel, -1, value = root.settings.e_feedrate, min_val = 0, max_val = 50000, size = (90, -1), digits = 1) | |
320 | root.efeedc.SetToolTip(wx.ToolTip(_("Extrude / Retract speed (mm/min)"))) | |
321 | root.efeedc.SetBackgroundColour((225, 200, 200)) | |
322 | root.efeedc.SetForegroundColour("black") | |
323 | root.efeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds) | |
324 | root.efeedc.Bind(wx.EVT_TEXT, root.setfeeds) | |
325 | add("efeed_val", root.efeedc, container = esettingssizer, flag = wx.ALIGN_CENTER | wx.RIGHT, border = 5) | |
326 | add("efeed_label", wx.StaticText(esettingspanel, -1, _("Speed:")), container = esettingssizer, flag = wx.ALIGN_LEFT) | |
327 | add("efeed_unit", wx.StaticText(esettingspanel, -1, _("mm/\nmin")), container = esettingssizer, flag = wx.ALIGN_CENTER) | |
328 | else: | |
329 | root.efeedc = None | |
330 | esettingspanel.SetSizer(esettingssizer) | |
331 | add("esettings", esettingspanel, flag = wx.ALIGN_LEFT) | |
332 | ||
333 | if not standalone_mode: | |
334 | ebuttonspanel = root.newPanel(parentpanel) | |
335 | ebuttonssizer = wx.BoxSizer(wx.HORIZONTAL) | |
336 | if root.settings.extruders > 1: | |
337 | etool_sel_panel = esettingspanel if mini_mode else ebuttonspanel | |
338 | etool_label = wx.StaticText(etool_sel_panel, -1, _("Tool:")) | |
339 | if root.settings.extruders == 2: | |
340 | root.extrudersel = wx.Button(etool_sel_panel, -1, "0", style = wx.BU_EXACTFIT) | |
341 | root.extrudersel.SetToolTip(wx.ToolTip(_("Click to switch current extruder"))) | |
342 | ||
343 | def extrudersel_cb(event): | |
344 | if root.extrudersel.GetLabel() == "1": | |
345 | new = "0" | |
346 | else: | |
347 | new = "1" | |
348 | root.extrudersel.SetLabel(new) | |
349 | root.tool_change(event) | |
350 | root.extrudersel.Bind(wx.EVT_BUTTON, extrudersel_cb) | |
351 | root.extrudersel.GetValue = root.extrudersel.GetLabel | |
352 | root.extrudersel.SetValue = root.extrudersel.SetLabel | |
353 | else: | |
354 | choices = [str(i) for i in range(0, root.settings.extruders)] | |
355 | root.extrudersel = wx.ComboBox(etool_sel_panel, -1, choices = choices, | |
356 | style = wx.CB_DROPDOWN | wx.CB_READONLY, | |
357 | size = (50, -1)) | |
358 | root.extrudersel.SetToolTip(wx.ToolTip(_("Select current extruder"))) | |
359 | root.extrudersel.SetValue(choices[0]) | |
360 | root.extrudersel.Bind(wx.EVT_COMBOBOX, root.tool_change) | |
361 | root.printerControls.append(root.extrudersel) | |
362 | if mini_mode: | |
363 | add("etool_label", etool_label, container = esettingssizer, flag = wx.ALIGN_CENTER) | |
364 | add("etool_val", root.extrudersel, container = esettingssizer) | |
365 | else: | |
366 | ebuttonssizer.Add(etool_label, flag = wx.ALIGN_CENTER) | |
367 | ebuttonssizer.Add(root.extrudersel) | |
368 | ||
369 | for key in ["extrude", "reverse"]: | |
370 | desc = root.cpbuttons[key] | |
371 | btn = make_custom_button(root, ebuttonspanel, desc, | |
372 | style = wx.BU_EXACTFIT) | |
373 | ebuttonssizer.Add(btn, 1, flag = wx.EXPAND) | |
374 | ||
375 | ebuttonspanel.SetSizer(ebuttonssizer) | |
376 | add("ebuttons", ebuttonspanel, flag = wx.EXPAND) | |
377 | else: | |
378 | for key, btn in extra_buttons.items(): | |
379 | add(key, btn, flag = wx.EXPAND) | |
380 | ||
381 | class ControlsSizer(wx.GridBagSizer): | |
382 | ||
383 | def __init__(self, root, parentpanel = None, standalone_mode = False, mini_mode = False): | |
384 | super(ControlsSizer, self).__init__() | |
385 | if not parentpanel: parentpanel = root.panel | |
386 | if mini_mode: self.make_mini(root, parentpanel) | |
387 | else: self.make_standard(root, parentpanel, standalone_mode) | |
388 | ||
389 | def make_standard(self, root, parentpanel, standalone_mode): | |
390 | lltspanel = root.newPanel(parentpanel) | |
391 | llts = wx.BoxSizer(wx.HORIZONTAL) | |
392 | lltspanel.SetSizer(llts) | |
393 | self.Add(lltspanel, pos = (0, 0), span = (1, 6)) | |
394 | xyzpanel = root.newPanel(parentpanel) | |
395 | self.xyzsizer = XYZControlsSizer(root, xyzpanel) | |
396 | xyzpanel.SetSizer(self.xyzsizer) | |
397 | self.Add(xyzpanel, pos = (1, 0), span = (1, 6), flag = wx.ALIGN_CENTER) | |
398 | ||
399 | self.extra_buttons = {} | |
400 | pos_mapping = {"extrude": (4, 0), | |
401 | "reverse": (4, 2), | |
402 | } | |
403 | span_mapping = {"extrude": (1, 2), | |
404 | "reverse": (1, 3), | |
405 | } | |
406 | for key, desc in root.cpbuttons.items(): | |
407 | if not standalone_mode and key in ["extrude", "reverse"]: | |
408 | continue | |
409 | panel = lltspanel if key == "motorsoff" else parentpanel | |
410 | btn = make_custom_button(root, panel, desc) | |
411 | if key == "motorsoff": | |
412 | llts.Add(btn) | |
413 | elif not standalone_mode: | |
414 | self.Add(btn, pos = pos_mapping[key], span = span_mapping[key], flag = wx.EXPAND) | |
415 | else: | |
416 | self.extra_buttons[key] = btn | |
417 | ||
418 | root.xyfeedc = wx.SpinCtrl(lltspanel, -1, str(root.settings.xy_feedrate), min = 0, max = 50000, size = (97, -1)) | |
419 | root.xyfeedc.SetToolTip(wx.ToolTip(_("Set Maximum Speed for X & Y axes (mm/min)"))) | |
420 | llts.Add(wx.StaticText(lltspanel, -1, _("XY:")), flag = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) | |
421 | llts.Add(root.xyfeedc) | |
422 | llts.Add(wx.StaticText(lltspanel, -1, _("mm/min Z:")), flag = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) | |
423 | root.zfeedc = wx.SpinCtrl(lltspanel, -1, str(root.settings.z_feedrate), min = 0, max = 50000, size = (90, -1)) | |
424 | root.zfeedc.SetToolTip(wx.ToolTip(_("Set Maximum Speed for Z axis (mm/min)"))) | |
425 | llts.Add(root.zfeedc,) | |
426 | ||
427 | root.xyfeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds) | |
428 | root.zfeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds) | |
429 | root.xyfeedc.Bind(wx.EVT_TEXT, root.setfeeds) | |
430 | root.zfeedc.Bind(wx.EVT_TEXT, root.setfeeds) | |
431 | root.zfeedc.SetBackgroundColour((180, 255, 180)) | |
432 | root.zfeedc.SetForegroundColour("black") | |
433 | ||
434 | if not standalone_mode: | |
435 | add_extra_controls(self, root, parentpanel, None) | |
436 | ||
437 | def make_mini(self, root, parentpanel): | |
438 | root.xyb = XYButtonsMini(parentpanel, root.moveXY, root.homeButtonClicked, | |
439 | root.spacebarAction, root.bgcolor, | |
440 | zcallback = root.moveZ) | |
441 | self.Add(root.xyb, pos = (1, 0), span = (1, 4), flag = wx.ALIGN_CENTER) | |
442 | root.zb = ZButtonsMini(parentpanel, root.moveZ, root.bgcolor) | |
443 | self.Add(root.zb, pos = (0, 4), span = (2, 1), flag = wx.ALIGN_CENTER) | |
444 | wx.CallAfter(root.xyb.SetFocus) | |
445 | ||
446 | pos_mapping = {"motorsoff": (0, 0), | |
447 | } | |
448 | span_mapping = {"motorsoff": (1, 4), | |
449 | } | |
450 | btn = make_custom_button(root, parentpanel, root.cpbuttons["motorsoff"]) | |
451 | self.Add(btn, pos = pos_mapping["motorsoff"], span = span_mapping["motorsoff"], flag = wx.EXPAND) | |
452 | ||
453 | add_extra_controls(self, root, parentpanel, None, True) |