printrun-src/printrun/gui/controls.py

Thu, 07 Jul 2016 11:58:38 +0200

author
mbayer
date
Thu, 07 Jul 2016 11:58:38 +0200
changeset 27
c82c30811edd
parent 26
5c98c7e24b02
child 33
eee51ca7cbe7
permissions
-rw-r--r--

svg crowbar fixes

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

mercurial