printrun-src/printrun/gui/toolbar.py

Sat, 23 Sep 2017 08:51:58 +0200

author
mdd
date
Sat, 23 Sep 2017 08:51:58 +0200
changeset 33
eee51ca7cbe7
parent 15
0bbb006204fc
child 46
cce0af6351f0
permissions
-rw-r--r--

Added support for multiple cutting passes with automatic Z refocusing

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)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
30 ToolbarSizer = wx.WrapSizer if use_wrapsizer and wx.VERSION > (2, 9) else wx.BoxSizer
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"],
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
45 style = wx.CB_DROPDOWN, size = (100, -1))
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"):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
55 root.connectbtn = make_autosize_button(parentpanel, _("Connect"), root.connect, _("Connect to the printer"))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
56 root.statefulControls.append(root.connectbtn)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
57 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
58 root.connectbtn.Reparent(parentpanel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
59 self.Add(root.connectbtn)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
60 if not hasattr(root, "resetbtn"):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
61 root.resetbtn = make_autosize_button(parentpanel, _("Reset"), root.reset, _("Reset the printer"))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
62 root.statefulControls.append(root.resetbtn)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
63 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
64 root.resetbtn.Reparent(parentpanel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
65 self.Add(root.resetbtn)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
66
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
67 self.AddStretchSpacer(prop = 1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
68
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
69 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
70 root.sdbtn = make_autosize_button(parentpanel, _("SD"), root.sdmenu, _("SD Card Printing"), self)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
71 root.sdbtn.Reparent(parentpanel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
72 root.printerControls.append(root.sdbtn)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
73 if not hasattr(root, "printbtn"):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
74 root.printbtn = make_autosize_button(parentpanel, _("Print"), root.printfile, _("Start Printing Loaded File"))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
75 root.statefulControls.append(root.printbtn)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
76 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
77 root.printbtn.Reparent(parentpanel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
78 self.Add(root.printbtn)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
79 if not hasattr(root, "pausebtn"):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
80 root.pausebtn = make_autosize_button(parentpanel, _("Pause"), root.pause, _("Pause Current Print"))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
81 root.statefulControls.append(root.pausebtn)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
82 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
83 root.pausebtn.Reparent(parentpanel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
84 self.Add(root.pausebtn)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
85 root.offbtn = make_autosize_button(parentpanel, _("Off"), root.off, _("Turn printer off"), self)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
86 root.printerControls.append(root.offbtn)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
87
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
88 self.AddStretchSpacer(prop = 4)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
89
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
90 if root.settings.lockbox:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
91 parentpanel.SetSizer(self)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
92 return glob
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
93 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
94 return self

mercurial