Wed, 20 Jan 2021 10:17:01 +0100
updated pronterface.py losing my own changes
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) | |
46 | 32 | root.xyb.SetToolTip(_('[J]og controls. (Shift)+TAB ESC Shift/Ctrl+(arrows PgUp/PgDn)')) |
15 | 33 | self.Add(root.xyb, pos = (0, 1), flag = wx.ALIGN_CENTER) |
34 | root.zb = ZButtons(parentpanel, root.moveZ, root.bgcolor) | |
35 | self.Add(root.zb, pos = (0, 2), flag = wx.ALIGN_CENTER) | |
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: | |
46 | 94 | pos_mapping["tempgraph"] = (base_line + 6, 0) |
95 | span_mapping["tempgraph"] = (3, 2) | |
15 | 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 | ||
133 | root.settoff = make_button(parentpanel, _("Off"), lambda e: root.do_settemp("off"), _("Switch Hotend Off"), size = (38, -1), style = wx.BU_EXACTFIT) | |
134 | root.printerControls.append(root.settoff) | |
135 | add("htemp_off", root.settoff) | |
136 | ||
46 | 137 | root.htemp = wx.ComboBox(parentpanel, style = wx.CB_DROPDOWN, size = (115, -1)) |
138 | root.htemp.SetToolTip(wx.ToolTip(_("Select Temperature for [H]otend"))) | |
15 | 139 | root.htemp.Bind(wx.EVT_COMBOBOX, root.htemp_change) |
140 | ||
141 | add("htemp_val", root.htemp) | |
142 | root.settbtn = make_button(parentpanel, _("Set"), root.do_settemp, _("Switch Hotend On"), size = (38, -1), style = wx.BU_EXACTFIT) | |
143 | root.printerControls.append(root.settbtn) | |
144 | add("htemp_set", root.settbtn, flag = wx.EXPAND) | |
145 | ||
146 | # Bed temp | |
147 | add("btemp_label", wx.StaticText(parentpanel, -1, _("Bed:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) | |
148 | ||
149 | root.setboff = make_button(parentpanel, _("Off"), lambda e: root.do_bedtemp("off"), _("Switch Heated Bed Off"), size = (38, -1), style = wx.BU_EXACTFIT) | |
150 | root.printerControls.append(root.setboff) | |
151 | add("btemp_off", root.setboff) | |
152 | ||
46 | 153 | root.btemp = wx.ComboBox(parentpanel, style = wx.CB_DROPDOWN, size = (115, -1)) |
154 | root.btemp.SetToolTip(wx.ToolTip(_("Select Temperature for Heated [B]ed"))) | |
15 | 155 | root.btemp.Bind(wx.EVT_COMBOBOX, root.btemp_change) |
156 | add("btemp_val", root.btemp) | |
157 | ||
158 | root.setbbtn = make_button(parentpanel, _("Set"), root.do_bedtemp, _("Switch Heated Bed On"), size = (38, -1), style = wx.BU_EXACTFIT) | |
159 | root.printerControls.append(root.setbbtn) | |
160 | add("btemp_set", root.setbbtn, flag = wx.EXPAND) | |
161 | ||
46 | 162 | def set_labeled(temp, choices, widget): |
163 | choices = [(float(p[1]), p[0]) for p in choices.items()] | |
164 | if not next((1 for p in choices if p[0] == temp), False): | |
165 | choices.append((temp, 'user')) | |
15 | 166 | |
46 | 167 | choices = sorted(choices) |
168 | widget.Items = ['%s (%s)'%tl for tl in choices] | |
169 | widget.Selection = next((i for i, tl in enumerate(choices) if tl[0] == temp), -1) | |
15 | 170 | |
46 | 171 | set_labeled(root.settings.last_bed_temperature, root.bedtemps, root.btemp) |
172 | set_labeled(root.settings.last_temperature, root.temps, root.htemp) | |
15 | 173 | |
174 | # Speed control # | |
175 | speedpanel = root.newPanel(parentpanel) | |
176 | speedsizer = wx.BoxSizer(wx.HORIZONTAL) | |
46 | 177 | speedsizer.Add(wx.StaticText(speedpanel, -1, _("Print speed:")), flag = wx.ALIGN_CENTER_VERTICAL) |
15 | 178 | |
179 | root.speed_slider = wx.Slider(speedpanel, -1, 100, 1, 300) | |
180 | speedsizer.Add(root.speed_slider, 1, flag = wx.EXPAND) | |
181 | ||
46 | 182 | root.speed_spin = wx.SpinCtrlDouble(speedpanel, -1, initial = 100, min = 1, max = 300, style = wx.ALIGN_LEFT, size = (115, -1)) |
183 | root.speed_spin.SetDigits(0) | |
15 | 184 | speedsizer.Add(root.speed_spin, 0, flag = wx.ALIGN_CENTER_VERTICAL) |
185 | root.speed_label = wx.StaticText(speedpanel, -1, _("%")) | |
46 | 186 | speedsizer.Add(root.speed_label, flag = wx.ALIGN_CENTER_VERTICAL) |
15 | 187 | |
188 | def speedslider_set(event): | |
189 | root.do_setspeed() | |
190 | root.speed_setbtn.SetBackgroundColour(wx.NullColour) | |
191 | root.speed_setbtn = make_button(speedpanel, _("Set"), speedslider_set, _("Set print speed factor"), size = (38, -1), style = wx.BU_EXACTFIT) | |
192 | root.printerControls.append(root.speed_setbtn) | |
193 | speedsizer.Add(root.speed_setbtn, flag = wx.ALIGN_CENTER) | |
194 | speedpanel.SetSizer(speedsizer) | |
195 | add("speedcontrol", speedpanel, flag = wx.EXPAND) | |
196 | ||
197 | def speedslider_spin(event): | |
198 | value = root.speed_spin.GetValue() | |
199 | root.speed_setbtn.SetBackgroundColour("red") | |
200 | root.speed_slider.SetValue(value) | |
46 | 201 | root.speed_spin.Bind(wx.EVT_SPINCTRLDOUBLE, speedslider_spin) |
15 | 202 | |
203 | def speedslider_scroll(event): | |
204 | value = root.speed_slider.GetValue() | |
205 | root.speed_setbtn.SetBackgroundColour("red") | |
206 | root.speed_spin.SetValue(value) | |
207 | root.speed_slider.Bind(wx.EVT_SCROLL, speedslider_scroll) | |
208 | ||
209 | # Flow control # | |
210 | flowpanel = root.newPanel(parentpanel) | |
211 | flowsizer = wx.BoxSizer(wx.HORIZONTAL) | |
46 | 212 | flowsizer.Add(wx.StaticText(flowpanel, -1, _("Print flow:")), flag = wx.ALIGN_CENTER_VERTICAL) |
15 | 213 | |
214 | root.flow_slider = wx.Slider(flowpanel, -1, 100, 1, 300) | |
215 | flowsizer.Add(root.flow_slider, 1, flag = wx.EXPAND) | |
216 | ||
46 | 217 | root.flow_spin = wx.SpinCtrlDouble(flowpanel, -1, initial = 100, min = 1, max = 300, style = wx.ALIGN_LEFT, size = (115, -1)) |
15 | 218 | flowsizer.Add(root.flow_spin, 0, flag = wx.ALIGN_CENTER_VERTICAL) |
219 | root.flow_label = wx.StaticText(flowpanel, -1, _("%")) | |
46 | 220 | flowsizer.Add(root.flow_label, flag = wx.ALIGN_CENTER_VERTICAL) |
15 | 221 | |
222 | def flowslider_set(event): | |
223 | root.do_setflow() | |
224 | root.flow_setbtn.SetBackgroundColour(wx.NullColour) | |
225 | root.flow_setbtn = make_button(flowpanel, _("Set"), flowslider_set, _("Set print flow factor"), size = (38, -1), style = wx.BU_EXACTFIT) | |
226 | root.printerControls.append(root.flow_setbtn) | |
227 | flowsizer.Add(root.flow_setbtn, flag = wx.ALIGN_CENTER) | |
228 | flowpanel.SetSizer(flowsizer) | |
229 | add("flowcontrol", flowpanel, flag = wx.EXPAND) | |
230 | ||
231 | def flowslider_spin(event): | |
232 | value = root.flow_spin.GetValue() | |
233 | root.flow_setbtn.SetBackgroundColour("red") | |
234 | root.flow_slider.SetValue(value) | |
46 | 235 | root.flow_spin.Bind(wx.EVT_SPINCTRLDOUBLE, flowslider_spin) |
15 | 236 | |
237 | def flowslider_scroll(event): | |
238 | value = root.flow_slider.GetValue() | |
239 | root.flow_setbtn.SetBackgroundColour("red") | |
240 | root.flow_spin.SetValue(value) | |
241 | root.flow_slider.Bind(wx.EVT_SCROLL, flowslider_scroll) | |
242 | ||
243 | # Temperature gauges # | |
244 | ||
245 | if root.display_gauges: | |
246 | root.hottgauge = TempGauge(parentpanel, size = (-1, 24), title = _("Heater:"), maxval = 300, bgcolor = root.bgcolor) | |
46 | 247 | root.hottgauge.SetTarget(root.settings.last_temperature) |
248 | # root.hsetpoint = root.settings.last_temperature | |
15 | 249 | add("htemp_gauge", root.hottgauge, flag = wx.EXPAND) |
250 | root.bedtgauge = TempGauge(parentpanel, size = (-1, 24), title = _("Bed:"), maxval = 150, bgcolor = root.bgcolor) | |
46 | 251 | root.bedtgauge.SetTarget(root.settings.last_bed_temperature) |
252 | # root.bsetpoint = root.settings.last_bed_temperature | |
15 | 253 | add("btemp_gauge", root.bedtgauge, flag = wx.EXPAND) |
254 | ||
46 | 255 | def scroll_gauge(rot, cmd, setpoint): |
256 | if rot: | |
257 | temp = setpoint + (1 if rot > 0 else -1) | |
258 | cmd(str(max(0, temp))) | |
259 | ||
260 | def hotend_handler(e): | |
261 | scroll_gauge(e.WheelRotation, root.do_settemp, root.hsetpoint) | |
15 | 262 | |
46 | 263 | def bed_handler(e): |
264 | scroll_gauge(e.WheelRotation, root.do_bedtemp, root.bsetpoint) | |
265 | root.hottgauge.Bind(wx.EVT_MOUSEWHEEL, hotend_handler) | |
266 | root.bedtgauge.Bind(wx.EVT_MOUSEWHEEL, bed_handler) | |
267 | ||
268 | def updateGauge(e, gauge): | |
269 | gauge.SetTarget(float(e.String.split()[0])) | |
270 | ||
271 | root.htemp.Bind(wx.EVT_TEXT, lambda e: updateGauge(e, root.hottgauge)) | |
272 | root.btemp.Bind(wx.EVT_TEXT, lambda e: updateGauge(e, root.bedtgauge)) | |
15 | 273 | |
274 | # Temperature (M105) feedback display # | |
275 | root.tempdisp = wx.StaticText(parentpanel, -1, "", style = wx.ST_NO_AUTORESIZE) | |
276 | ||
277 | def on_tempdisp_size(evt): | |
278 | root.tempdisp.Wrap(root.tempdisp.GetSize().width) | |
279 | root.tempdisp.Bind(wx.EVT_SIZE, on_tempdisp_size) | |
280 | ||
281 | def tempdisp_setlabel(label): | |
282 | wx.StaticText.SetLabel(root.tempdisp, label) | |
283 | root.tempdisp.Wrap(root.tempdisp.GetSize().width) | |
284 | root.tempdisp.SetSize((-1, root.tempdisp.GetBestSize().height)) | |
285 | root.tempdisp.SetLabel = tempdisp_setlabel | |
286 | add("tempdisp", root.tempdisp, flag = wx.EXPAND) | |
287 | ||
288 | # Temperature graph # | |
289 | ||
290 | if root.display_graph: | |
291 | root.graph = Graph(parentpanel, wx.ID_ANY, root) | |
292 | add("tempgraph", root.graph, flag = wx.EXPAND | wx.ALL, border = 5) | |
293 | root.graph.Bind(wx.EVT_LEFT_DOWN, root.graph.show_graph_window) | |
294 | ||
295 | # Extrusion controls # | |
296 | ||
297 | # Extrusion settings | |
298 | esettingspanel = root.newPanel(parentpanel) | |
299 | esettingssizer = wx.GridBagSizer() | |
300 | esettingssizer.SetEmptyCellSize((0, 0)) | |
46 | 301 | root.edist = wx.SpinCtrlDouble(esettingspanel, -1, initial = root.settings.last_extrusion, min = 0, max = 1000, size = (135, -1)) |
302 | root.edist.SetDigits(1) | |
303 | root.edist.Bind(wx.EVT_SPINCTRLDOUBLE, root.setfeeds) | |
15 | 304 | root.edist.SetBackgroundColour((225, 200, 200)) |
305 | root.edist.SetForegroundColour("black") | |
306 | root.edist.Bind(wx.EVT_TEXT, root.setfeeds) | |
307 | add("edist_label", wx.StaticText(esettingspanel, -1, _("Length:")), container = esettingssizer, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.RIGHT | wx.LEFT, border = 5) | |
308 | add("edist_val", root.edist, container = esettingssizer, flag = wx.ALIGN_CENTER | wx.RIGHT, border = 5) | |
309 | unit_label = _("mm") if mini_mode else _("mm @") | |
310 | add("edist_unit", wx.StaticText(esettingspanel, -1, unit_label), container = esettingssizer, flag = wx.ALIGN_CENTER | wx.RIGHT, border = 5) | |
311 | root.edist.SetToolTip(wx.ToolTip(_("Amount to Extrude or Retract (mm)"))) | |
312 | if not mini_mode: | |
46 | 313 | root.efeedc = wx.SpinCtrlDouble(esettingspanel, -1, initial = root.settings.e_feedrate, min = 0, max = 50000, size = (145, -1)) |
314 | root.efeedc.SetDigits(1) | |
315 | root.efeedc.Bind(wx.EVT_SPINCTRLDOUBLE, root.setfeeds) | |
15 | 316 | root.efeedc.SetToolTip(wx.ToolTip(_("Extrude / Retract speed (mm/min)"))) |
317 | root.efeedc.SetBackgroundColour((225, 200, 200)) | |
318 | root.efeedc.SetForegroundColour("black") | |
319 | root.efeedc.Bind(wx.EVT_TEXT, root.setfeeds) | |
320 | add("efeed_val", root.efeedc, container = esettingssizer, flag = wx.ALIGN_CENTER | wx.RIGHT, border = 5) | |
321 | add("efeed_label", wx.StaticText(esettingspanel, -1, _("Speed:")), container = esettingssizer, flag = wx.ALIGN_LEFT) | |
322 | add("efeed_unit", wx.StaticText(esettingspanel, -1, _("mm/\nmin")), container = esettingssizer, flag = wx.ALIGN_CENTER) | |
323 | else: | |
324 | root.efeedc = None | |
325 | esettingspanel.SetSizer(esettingssizer) | |
326 | add("esettings", esettingspanel, flag = wx.ALIGN_LEFT) | |
327 | ||
328 | if not standalone_mode: | |
329 | ebuttonspanel = root.newPanel(parentpanel) | |
330 | ebuttonssizer = wx.BoxSizer(wx.HORIZONTAL) | |
331 | if root.settings.extruders > 1: | |
332 | etool_sel_panel = esettingspanel if mini_mode else ebuttonspanel | |
333 | etool_label = wx.StaticText(etool_sel_panel, -1, _("Tool:")) | |
334 | if root.settings.extruders == 2: | |
335 | root.extrudersel = wx.Button(etool_sel_panel, -1, "0", style = wx.BU_EXACTFIT) | |
336 | root.extrudersel.SetToolTip(wx.ToolTip(_("Click to switch current extruder"))) | |
337 | ||
338 | def extrudersel_cb(event): | |
339 | if root.extrudersel.GetLabel() == "1": | |
340 | new = "0" | |
341 | else: | |
342 | new = "1" | |
343 | root.extrudersel.SetLabel(new) | |
344 | root.tool_change(event) | |
345 | root.extrudersel.Bind(wx.EVT_BUTTON, extrudersel_cb) | |
346 | root.extrudersel.GetValue = root.extrudersel.GetLabel | |
347 | root.extrudersel.SetValue = root.extrudersel.SetLabel | |
348 | else: | |
349 | choices = [str(i) for i in range(0, root.settings.extruders)] | |
350 | root.extrudersel = wx.ComboBox(etool_sel_panel, -1, choices = choices, | |
351 | style = wx.CB_DROPDOWN | wx.CB_READONLY, | |
352 | size = (50, -1)) | |
353 | root.extrudersel.SetToolTip(wx.ToolTip(_("Select current extruder"))) | |
354 | root.extrudersel.SetValue(choices[0]) | |
355 | root.extrudersel.Bind(wx.EVT_COMBOBOX, root.tool_change) | |
356 | root.printerControls.append(root.extrudersel) | |
357 | if mini_mode: | |
358 | add("etool_label", etool_label, container = esettingssizer, flag = wx.ALIGN_CENTER) | |
359 | add("etool_val", root.extrudersel, container = esettingssizer) | |
360 | else: | |
361 | ebuttonssizer.Add(etool_label, flag = wx.ALIGN_CENTER) | |
362 | ebuttonssizer.Add(root.extrudersel) | |
363 | ||
364 | for key in ["extrude", "reverse"]: | |
365 | desc = root.cpbuttons[key] | |
366 | btn = make_custom_button(root, ebuttonspanel, desc, | |
367 | style = wx.BU_EXACTFIT) | |
368 | ebuttonssizer.Add(btn, 1, flag = wx.EXPAND) | |
369 | ||
370 | ebuttonspanel.SetSizer(ebuttonssizer) | |
371 | add("ebuttons", ebuttonspanel, flag = wx.EXPAND) | |
372 | else: | |
373 | for key, btn in extra_buttons.items(): | |
374 | add(key, btn, flag = wx.EXPAND) | |
375 | ||
376 | class ControlsSizer(wx.GridBagSizer): | |
377 | ||
378 | def __init__(self, root, parentpanel = None, standalone_mode = False, mini_mode = False): | |
379 | super(ControlsSizer, self).__init__() | |
380 | if not parentpanel: parentpanel = root.panel | |
381 | if mini_mode: self.make_mini(root, parentpanel) | |
382 | else: self.make_standard(root, parentpanel, standalone_mode) | |
383 | ||
384 | def make_standard(self, root, parentpanel, standalone_mode): | |
385 | lltspanel = root.newPanel(parentpanel) | |
386 | llts = wx.BoxSizer(wx.HORIZONTAL) | |
387 | lltspanel.SetSizer(llts) | |
388 | self.Add(lltspanel, pos = (0, 0), span = (1, 6)) | |
389 | xyzpanel = root.newPanel(parentpanel) | |
390 | self.xyzsizer = XYZControlsSizer(root, xyzpanel) | |
391 | xyzpanel.SetSizer(self.xyzsizer) | |
392 | self.Add(xyzpanel, pos = (1, 0), span = (1, 6), flag = wx.ALIGN_CENTER) | |
393 | ||
394 | self.extra_buttons = {} | |
395 | pos_mapping = {"extrude": (4, 0), | |
396 | "reverse": (4, 2), | |
397 | } | |
398 | span_mapping = {"extrude": (1, 2), | |
399 | "reverse": (1, 3), | |
400 | } | |
401 | for key, desc in root.cpbuttons.items(): | |
402 | if not standalone_mode and key in ["extrude", "reverse"]: | |
403 | continue | |
404 | panel = lltspanel if key == "motorsoff" else parentpanel | |
405 | btn = make_custom_button(root, panel, desc) | |
406 | if key == "motorsoff": | |
407 | llts.Add(btn) | |
408 | elif not standalone_mode: | |
409 | self.Add(btn, pos = pos_mapping[key], span = span_mapping[key], flag = wx.EXPAND) | |
410 | else: | |
411 | self.extra_buttons[key] = btn | |
412 | ||
46 | 413 | root.xyfeedc = wx.SpinCtrl(lltspanel, -1, str(root.settings.xy_feedrate), min = 0, max = 50000, size = (130, -1)) |
15 | 414 | root.xyfeedc.SetToolTip(wx.ToolTip(_("Set Maximum Speed for X & Y axes (mm/min)"))) |
46 | 415 | llts.Add(wx.StaticText(lltspanel, -1, _("XY:")), flag = wx.ALIGN_CENTER_VERTICAL) |
15 | 416 | llts.Add(root.xyfeedc) |
46 | 417 | llts.Add(wx.StaticText(lltspanel, -1, _("mm/min Z:")), flag = wx.ALIGN_CENTER_VERTICAL) |
418 | root.zfeedc = wx.SpinCtrl(lltspanel, -1, str(root.settings.z_feedrate), min = 0, max = 50000, size = (130, -1)) | |
15 | 419 | root.zfeedc.SetToolTip(wx.ToolTip(_("Set Maximum Speed for Z axis (mm/min)"))) |
420 | llts.Add(root.zfeedc,) | |
421 | ||
422 | root.xyfeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds) | |
423 | root.zfeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds) | |
424 | root.xyfeedc.Bind(wx.EVT_TEXT, root.setfeeds) | |
425 | root.zfeedc.Bind(wx.EVT_TEXT, root.setfeeds) | |
426 | root.zfeedc.SetBackgroundColour((180, 255, 180)) | |
427 | root.zfeedc.SetForegroundColour("black") | |
428 | ||
429 | if not standalone_mode: | |
430 | add_extra_controls(self, root, parentpanel, None) | |
431 | ||
432 | def make_mini(self, root, parentpanel): | |
433 | root.xyb = XYButtonsMini(parentpanel, root.moveXY, root.homeButtonClicked, | |
434 | root.spacebarAction, root.bgcolor, | |
435 | zcallback = root.moveZ) | |
436 | self.Add(root.xyb, pos = (1, 0), span = (1, 4), flag = wx.ALIGN_CENTER) | |
437 | root.zb = ZButtonsMini(parentpanel, root.moveZ, root.bgcolor) | |
438 | self.Add(root.zb, pos = (0, 4), span = (2, 1), flag = wx.ALIGN_CENTER) | |
439 | wx.CallAfter(root.xyb.SetFocus) | |
440 | ||
441 | pos_mapping = {"motorsoff": (0, 0), | |
442 | } | |
443 | span_mapping = {"motorsoff": (1, 4), | |
444 | } | |
445 | btn = make_custom_button(root, parentpanel, root.cpbuttons["motorsoff"]) | |
446 | self.Add(btn, pos = pos_mapping["motorsoff"], span = span_mapping["motorsoff"], flag = wx.EXPAND) | |
447 | ||
448 | add_extra_controls(self, root, parentpanel, None, True) |