Wed, 20 Jan 2021 10:15:13 +0100
updated and added new files for printrun
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) | |
46 | 30 | ToolbarSizer = wx.WrapSizer if use_wrapsizer else wx.BoxSizer |
15 | 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"], | |
46 | 45 | style = wx.CB_DROPDOWN, size = (110, -1)) |
15 | 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"): | |
46 | 55 | root.connectbtn_cb_var = root.connect |
56 | root.connectbtn = make_autosize_button(parentpanel, _("&Connect"), root.connectbtn_cb, _("Connect to the printer")) | |
15 | 57 | root.statefulControls.append(root.connectbtn) |
58 | else: | |
59 | root.connectbtn.Reparent(parentpanel) | |
60 | self.Add(root.connectbtn) | |
61 | if not hasattr(root, "resetbtn"): | |
62 | root.resetbtn = make_autosize_button(parentpanel, _("Reset"), root.reset, _("Reset the printer")) | |
63 | root.statefulControls.append(root.resetbtn) | |
64 | else: | |
65 | root.resetbtn.Reparent(parentpanel) | |
66 | self.Add(root.resetbtn) | |
67 | ||
68 | self.AddStretchSpacer(prop = 1) | |
69 | ||
70 | root.loadbtn = make_autosize_button(parentpanel, _("Load file"), root.loadfile, _("Load a 3D model file"), self) | |
71 | root.sdbtn = make_autosize_button(parentpanel, _("SD"), root.sdmenu, _("SD Card Printing"), self) | |
72 | root.sdbtn.Reparent(parentpanel) | |
73 | root.printerControls.append(root.sdbtn) | |
74 | if not hasattr(root, "printbtn"): | |
75 | root.printbtn = make_autosize_button(parentpanel, _("Print"), root.printfile, _("Start Printing Loaded File")) | |
76 | root.statefulControls.append(root.printbtn) | |
77 | else: | |
78 | root.printbtn.Reparent(parentpanel) | |
79 | self.Add(root.printbtn) | |
80 | if not hasattr(root, "pausebtn"): | |
81 | root.pausebtn = make_autosize_button(parentpanel, _("Pause"), root.pause, _("Pause Current Print")) | |
82 | root.statefulControls.append(root.pausebtn) | |
83 | else: | |
84 | root.pausebtn.Reparent(parentpanel) | |
85 | self.Add(root.pausebtn) | |
86 | root.offbtn = make_autosize_button(parentpanel, _("Off"), root.off, _("Turn printer off"), self) | |
87 | root.printerControls.append(root.offbtn) | |
88 | ||
89 | self.AddStretchSpacer(prop = 4) | |
90 | ||
91 | if root.settings.lockbox: | |
92 | parentpanel.SetSizer(self) | |
93 | return glob | |
94 | else: | |
95 | return self |