printrun-src/printrun/gui/toolbar.py

Wed, 20 Jan 2021 10:15:13 +0100

author
mdd
date
Wed, 20 Jan 2021 10:15:13 +0100
changeset 46
cce0af6351f0
parent 15
0bbb006204fc
permissions
-rw-r--r--

updated and added new files for printrun

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

mercurial