Thu, 23 Aug 2018 12:32:26 +0200
SVG gcode generator: interpret color style if present
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 .utils import make_autosize_button | |
19 | ||
20 | def MainToolbar(root, parentpanel = None, use_wrapsizer = False): | |
21 | if not parentpanel: parentpanel = root.panel | |
22 | if root.settings.lockbox: | |
23 | root.locker = wx.CheckBox(parentpanel, label = _("Lock") + " ") | |
24 | root.locker.Bind(wx.EVT_CHECKBOX, root.lock) | |
25 | root.locker.SetToolTip(wx.ToolTip(_("Lock graphical interface"))) | |
26 | glob = wx.BoxSizer(wx.HORIZONTAL) | |
27 | parentpanel = root.newPanel(parentpanel) | |
28 | glob.Add(parentpanel, 1, flag = wx.EXPAND) | |
29 | glob.Add(root.locker, 0, flag = wx.ALIGN_CENTER) | |
30 | ToolbarSizer = wx.WrapSizer if use_wrapsizer and wx.VERSION > (2, 9) else wx.BoxSizer | |
31 | self = ToolbarSizer(wx.HORIZONTAL) | |
32 | root.rescanbtn = make_autosize_button(parentpanel, _("Port"), root.rescanports, _("Communication Settings\nClick to rescan ports")) | |
33 | self.Add(root.rescanbtn, 0, wx.TOP | wx.LEFT, 0) | |
34 | ||
35 | root.serialport = wx.ComboBox(parentpanel, -1, choices = root.scanserial(), | |
36 | style = wx.CB_DROPDOWN) | |
37 | root.serialport.SetToolTip(wx.ToolTip(_("Select Port Printer is connected to"))) | |
38 | root.rescanports() | |
39 | self.Add(root.serialport) | |
40 | ||
41 | self.Add(wx.StaticText(parentpanel, -1, "@"), 0, wx.RIGHT | wx.ALIGN_CENTER, 0) | |
42 | root.baud = wx.ComboBox(parentpanel, -1, | |
43 | choices = ["2400", "9600", "19200", "38400", | |
44 | "57600", "115200", "250000"], | |
45 | style = wx.CB_DROPDOWN, size = (100, -1)) | |
46 | root.baud.SetToolTip(wx.ToolTip(_("Select Baud rate for printer communication"))) | |
47 | try: | |
48 | root.baud.SetValue("115200") | |
49 | root.baud.SetValue(str(root.settings.baudrate)) | |
50 | except: | |
51 | pass | |
52 | self.Add(root.baud) | |
53 | ||
54 | if not hasattr(root, "connectbtn"): | |
55 | root.connectbtn = make_autosize_button(parentpanel, _("Connect"), root.connect, _("Connect to the printer")) | |
56 | root.statefulControls.append(root.connectbtn) | |
57 | else: | |
58 | root.connectbtn.Reparent(parentpanel) | |
59 | self.Add(root.connectbtn) | |
60 | if not hasattr(root, "resetbtn"): | |
61 | root.resetbtn = make_autosize_button(parentpanel, _("Reset"), root.reset, _("Reset the printer")) | |
62 | root.statefulControls.append(root.resetbtn) | |
63 | else: | |
64 | root.resetbtn.Reparent(parentpanel) | |
65 | self.Add(root.resetbtn) | |
66 | ||
67 | self.AddStretchSpacer(prop = 1) | |
68 | ||
69 | root.loadbtn = make_autosize_button(parentpanel, _("Load file"), root.loadfile, _("Load a 3D model file"), self) | |
70 | root.sdbtn = make_autosize_button(parentpanel, _("SD"), root.sdmenu, _("SD Card Printing"), self) | |
71 | root.sdbtn.Reparent(parentpanel) | |
72 | root.printerControls.append(root.sdbtn) | |
73 | if not hasattr(root, "printbtn"): | |
74 | root.printbtn = make_autosize_button(parentpanel, _("Print"), root.printfile, _("Start Printing Loaded File")) | |
75 | root.statefulControls.append(root.printbtn) | |
76 | else: | |
77 | root.printbtn.Reparent(parentpanel) | |
78 | self.Add(root.printbtn) | |
79 | if not hasattr(root, "pausebtn"): | |
80 | root.pausebtn = make_autosize_button(parentpanel, _("Pause"), root.pause, _("Pause Current Print")) | |
81 | root.statefulControls.append(root.pausebtn) | |
82 | else: | |
83 | root.pausebtn.Reparent(parentpanel) | |
84 | self.Add(root.pausebtn) | |
85 | root.offbtn = make_autosize_button(parentpanel, _("Off"), root.off, _("Turn printer off"), self) | |
86 | root.printerControls.append(root.offbtn) | |
87 | ||
88 | self.AddStretchSpacer(prop = 4) | |
89 | ||
90 | if root.settings.lockbox: | |
91 | parentpanel.SetSizer(self) | |
92 | return glob | |
93 | else: | |
94 | return self |