printrun-src/printrun/gui/__init__.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 logging
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
17
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
18 try:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
19 import wx
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
20 if wx.VERSION < (4,):
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
21 raise ImportError()
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
22 except:
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
23 logging.error(_("WX >= 4 is not installed. This program requires WX >= 4 to run."))
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
24 raise
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
25
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
26 from printrun.utils import install_locale
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
27 install_locale('pronterface')
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
28
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
29 from .controls import ControlsSizer, add_extra_controls
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
30 from .viz import VizPane
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
31 from .log import LogPane
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
32 from .toolbar import MainToolbar
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
33
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
34 class ToggleablePane(wx.BoxSizer):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
35
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
36 def __init__(self, root, label, parentpanel, parentsizers):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
37 super(ToggleablePane, self).__init__(wx.HORIZONTAL)
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
38 if not parentpanel:
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
39 parentpanel = root.panel
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
40 self.root = root
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
41 self.visible = True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
42 self.parentpanel = parentpanel
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
43 self.parentsizers = parentsizers
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
44 self.panepanel = root.newPanel(parentpanel)
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
45 self.button = wx.Button(parentpanel, -1, label, size = (35, 18), style = wx.BU_EXACTFIT)
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
46 self.button.Bind(wx.EVT_BUTTON, self.toggle)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
47
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
48 def toggle(self, event):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
49 if self.visible:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
50 self.Hide(self.panepanel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
51 self.on_hide()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
52 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
53 self.Show(self.panepanel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
54 self.on_show()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
55 self.visible = not self.visible
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
56 self.button.SetLabel(">" if self.button.GetLabel() == "<" else "<")
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
57
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
58 class LeftPaneToggleable(ToggleablePane):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
59 def __init__(self, root, parentpanel, parentsizers):
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
60 super().__init__(root, "<", parentpanel, parentsizers)
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
61 self.Add(self.panepanel, 0, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
62 self.Add(self.button, 0)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
63
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
64 def set_sizer(self, sizer):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
65 self.panepanel.SetSizer(sizer)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
66
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
67 def on_show(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
68 for sizer in self.parentsizers:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
69 sizer.Layout()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
70
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
71 def on_hide(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
72 for sizer in self.parentsizers:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
73 # Expand right splitterwindow
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
74 if isinstance(sizer, wx.SplitterWindow):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
75 if sizer.shrinked:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
76 button_width = self.button.GetSize()[0]
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
77 sizer.SetSashPosition(sizer.GetSize()[0] - button_width)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
78 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
79 sizer.Layout()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
80
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
81 class LogPaneToggleable(ToggleablePane):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
82 def __init__(self, root, parentpanel, parentsizers):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
83 super(LogPaneToggleable, self).__init__(root, ">", parentpanel, parentsizers)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
84 self.Add(self.button, 0)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
85 pane = LogPane(root, self.panepanel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
86 self.panepanel.SetSizer(pane)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
87 self.Add(self.panepanel, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
88 self.splitter = self.parentpanel.GetParent()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
89
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
90 def on_show(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
91 self.splitter.shrinked = False
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
92 self.splitter.SetSashPosition(self.splitter.GetSize()[0] - self.orig_width)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
93 self.splitter.SetMinimumPaneSize(self.orig_min_size)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
94 self.splitter.SetSashGravity(self.orig_gravity)
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
95 if getattr(self.splitter, 'SetSashSize', False):
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
96 self.splitter.SetSashSize(self.orig_sash_size)
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
97 getattr(self.splitter, 'SetSashInvisible', bool)(False)
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
98 for sizer in self.parentsizers:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
99 sizer.Layout()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
100
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
101 def on_hide(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
102 self.splitter.shrinked = True
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
103 self.orig_width = self.splitter.GetSize()[0] - self.splitter.GetSashPosition()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
104 button_width = self.button.GetSize()[0]
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
105 self.orig_min_size = self.splitter.GetMinimumPaneSize()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
106 self.orig_gravity = self.splitter.GetSashGravity()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
107 self.splitter.SetMinimumPaneSize(button_width)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
108 self.splitter.SetSashGravity(1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
109 self.splitter.SetSashPosition(self.splitter.GetSize()[0] - button_width)
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
110 if getattr(self.splitter, 'SetSashSize', False):
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
111 self.orig_sash_size = self.splitter.GetSashSize()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
112 self.splitter.SetSashSize(0)
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
113 getattr(self.splitter, 'SetSashInvisible', bool)(True)
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
114 for sizer in self.parentsizers:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
115 sizer.Layout()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
116
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
117 class MainWindow(wx.Frame):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
118
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
119 def __init__(self, *args, **kwargs):
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
120 super().__init__(*args, **kwargs)
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
121 # this list will contain all controls that should be only enabled
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
122 # when we're connected to a printer
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
123 self.panel = wx.Panel(self)
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
124 self.reset_ui()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
125 self.statefulControls = []
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
126
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
127 def reset_ui(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
128 self.panels = []
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
129 self.printerControls = []
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
130
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
131 def newPanel(self, parent, add_to_list = True):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
132 panel = wx.Panel(parent)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
133 self.registerPanel(panel, add_to_list)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
134 return panel
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
135
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
136 def registerPanel(self, panel, add_to_list = True):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
137 panel.SetBackgroundColour(self.bgcolor)
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
138 if add_to_list:
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
139 self.panels.append(panel)
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
140
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
141 def createTabbedGui(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
142 self.notesizer = wx.BoxSizer(wx.VERTICAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
143 self.notebook = wx.Notebook(self.panel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
144 self.notebook.SetBackgroundColour(self.bgcolor)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
145 page1panel = self.newPanel(self.notebook)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
146 page2panel = self.newPanel(self.notebook)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
147 self.mainsizer_page1 = wx.BoxSizer(wx.VERTICAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
148 page1panel1 = self.newPanel(page1panel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
149 page1panel2 = self.newPanel(page1panel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
150 self.toolbarsizer = MainToolbar(self, page1panel1, use_wrapsizer = True)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
151 page1panel1.SetSizer(self.toolbarsizer)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
152 self.mainsizer_page1.Add(page1panel1, 0, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
153 self.lowersizer = wx.BoxSizer(wx.HORIZONTAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
154 page1panel2.SetSizer(self.lowersizer)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
155 leftsizer = wx.BoxSizer(wx.VERTICAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
156 controls_sizer = ControlsSizer(self, page1panel2, True)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
157 leftsizer.Add(controls_sizer, 1, wx.ALIGN_CENTER)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
158 rightsizer = wx.BoxSizer(wx.VERTICAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
159 extracontrols = wx.GridBagSizer()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
160 add_extra_controls(extracontrols, self, page1panel2, controls_sizer.extra_buttons)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
161 rightsizer.AddStretchSpacer()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
162 rightsizer.Add(extracontrols, 0, wx.ALIGN_CENTER)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
163 self.lowersizer.Add(leftsizer, 0, wx.ALIGN_CENTER | wx.RIGHT, border = 10)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
164 self.lowersizer.Add(rightsizer, 1, wx.ALIGN_CENTER)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
165 self.mainsizer_page1.Add(page1panel2, 1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
166 self.mainsizer = wx.BoxSizer(wx.HORIZONTAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
167 self.splitterwindow = wx.SplitterWindow(page2panel, style = wx.SP_3D)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
168 page2sizer1 = wx.BoxSizer(wx.HORIZONTAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
169 page2panel1 = self.newPanel(self.splitterwindow)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
170 page2sizer2 = wx.BoxSizer(wx.HORIZONTAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
171 page2panel2 = self.newPanel(self.splitterwindow)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
172 vizpane = VizPane(self, page2panel1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
173 page2sizer1.Add(vizpane, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
174 page2sizer2.Add(LogPane(self, page2panel2), 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
175 page2panel1.SetSizer(page2sizer1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
176 page2panel2.SetSizer(page2sizer2)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
177 self.splitterwindow.SetMinimumPaneSize(1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
178 self.splitterwindow.SetSashGravity(0.5)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
179 self.splitterwindow.SplitVertically(page2panel1, page2panel2,
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
180 self.settings.last_sash_position)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
181 self.mainsizer.Add(self.splitterwindow, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
182 page1panel.SetSizer(self.mainsizer_page1)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
183 page2panel.SetSizer(self.mainsizer)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
184 self.notesizer.Add(self.notebook, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
185 self.notebook.AddPage(page1panel, _("Commands"))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
186 self.notebook.AddPage(page2panel, _("Status"))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
187 if self.settings.uimode == _("Tabbed with platers"):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
188 from printrun.stlplater import StlPlaterPanel
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
189 from printrun.gcodeplater import GcodePlaterPanel
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
190 page3panel = StlPlaterPanel(parent = self.notebook,
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
191 callback = self.platecb,
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
192 build_dimensions = self.build_dimensions_list,
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
193 circular_platform = self.settings.circular_bed,
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
194 simarrange_path = self.settings.simarrange_path,
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
195 antialias_samples = int(self.settings.antialias3dsamples))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
196 page4panel = GcodePlaterPanel(parent = self.notebook,
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
197 callback = self.platecb,
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
198 build_dimensions = self.build_dimensions_list,
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
199 circular_platform = self.settings.circular_bed,
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
200 antialias_samples = int(self.settings.antialias3dsamples))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
201 self.registerPanel(page3panel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
202 self.registerPanel(page4panel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
203 self.notebook.AddPage(page3panel, _("Plater"))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
204 self.notebook.AddPage(page4panel, _("G-Code Plater"))
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
205 self.panel.SetSizer(self.notesizer)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
206 self.panel.Bind(wx.EVT_MOUSE_EVENTS, self.editbutton)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
207
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
208 # Custom buttons
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
209 self.cbuttonssizer = wx.WrapSizer(wx.HORIZONTAL)
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
210 self.centerpanel = self.newPanel(page1panel2)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
211 self.centerpanel.SetSizer(self.cbuttonssizer)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
212 rightsizer.Add(self.centerpanel, 0, wx.ALIGN_CENTER)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
213 rightsizer.AddStretchSpacer()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
214
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
215 self.panel.SetSizerAndFit(self.notesizer)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
216
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
217 self.cbuttons_reload()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
218 minsize = self.lowersizer.GetMinSize() # lower pane
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
219 minsize[1] = self.notebook.GetSize()[1]
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
220 self.SetMinSize(self.ClientToWindowSize(minsize)) # client to window
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
221 self.Fit()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
222
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
223 def createGui(self, compact = False, mini = False):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
224 self.mainsizer = wx.BoxSizer(wx.VERTICAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
225 self.lowersizer = wx.BoxSizer(wx.HORIZONTAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
226 upperpanel = self.newPanel(self.panel, False)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
227 self.toolbarsizer = MainToolbar(self, upperpanel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
228 lowerpanel = self.newPanel(self.panel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
229 upperpanel.SetSizer(self.toolbarsizer)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
230 lowerpanel.SetSizer(self.lowersizer)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
231 leftpanel = self.newPanel(lowerpanel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
232 left_pane = LeftPaneToggleable(self, leftpanel, [self.lowersizer])
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
233 leftpanel.SetSizer(left_pane)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
234 left_real_panel = left_pane.panepanel
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
235 controls_panel = self.newPanel(left_real_panel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
236 controls_sizer = ControlsSizer(self, controls_panel, mini_mode = mini)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
237 controls_panel.SetSizer(controls_sizer)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
238 left_sizer = wx.BoxSizer(wx.VERTICAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
239 left_sizer.Add(controls_panel, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
240 left_pane.set_sizer(left_sizer)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
241 self.lowersizer.Add(leftpanel, 0, wx.EXPAND)
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
242 if compact:
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
243 vizpanel = self.newPanel(lowerpanel)
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
244 logpanel = self.newPanel(left_real_panel)
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
245 else:
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
246 # Use a splitterwindow to group viz and log
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
247 rightpanel = self.newPanel(lowerpanel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
248 rightsizer = wx.BoxSizer(wx.VERTICAL)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
249 rightpanel.SetSizer(rightsizer)
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
250 self.splitterwindow = wx.SplitterWindow(rightpanel, style = wx.SP_3D | wx.SP_LIVE_UPDATE)
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
251 self.splitterwindow.SetMinimumPaneSize(150)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
252 self.splitterwindow.SetSashGravity(0.8)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
253 rightsizer.Add(self.splitterwindow, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
254 vizpanel = self.newPanel(self.splitterwindow)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
255 logpanel = self.newPanel(self.splitterwindow)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
256 self.splitterwindow.SplitVertically(vizpanel, logpanel,
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
257 self.settings.last_sash_position)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
258 self.splitterwindow.shrinked = False
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
259 viz_pane = VizPane(self, vizpanel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
260 # Custom buttons
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
261 self.cbuttonssizer = wx.WrapSizer(wx.HORIZONTAL)
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
262 self.centerpanel = self.newPanel(vizpanel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
263 self.centerpanel.SetSizer(self.cbuttonssizer)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
264 viz_pane.Add(self.centerpanel, 0, flag = wx.ALIGN_CENTER)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
265 vizpanel.SetSizer(viz_pane)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
266 if compact:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
267 log_pane = LogPane(self, logpanel)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
268 else:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
269 log_pane = LogPaneToggleable(self, logpanel, [self.lowersizer])
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
270 left_pane.parentsizers.append(self.splitterwindow)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
271 logpanel.SetSizer(log_pane)
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
272 if compact:
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
273 left_sizer.Add(logpanel, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
274 self.lowersizer.Add(vizpanel, 1, wx.EXPAND)
46
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
275 else:
cce0af6351f0 updated and added new files for printrun
mdd
parents: 15
diff changeset
276 self.lowersizer.Add(rightpanel, 1, wx.EXPAND)
15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
277 self.mainsizer.Add(upperpanel, 0, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
278 self.mainsizer.Add(lowerpanel, 1, wx.EXPAND)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
279 self.panel.SetSizer(self.mainsizer)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
280 self.panel.Bind(wx.EVT_MOUSE_EVENTS, self.editbutton)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
281
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
282 self.mainsizer.Layout()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
283 # This prevents resizing below a reasonnable value
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
284 # We sum the lowersizer (left pane / viz / log) min size
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
285 # the toolbar height and the statusbar/menubar sizes
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
286 minsize = [0, 0]
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
287 minsize[0] = self.lowersizer.GetMinSize()[0] # lower pane
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
288 minsize[1] = max(viz_pane.GetMinSize()[1], controls_sizer.GetMinSize()[1])
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
289 minsize[1] += self.toolbarsizer.GetMinSize()[1] # toolbar height
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
290 displaysize = wx.DisplaySize()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
291 minsize[0] = min(minsize[0], displaysize[0])
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
292 minsize[1] = min(minsize[1], displaysize[1])
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
293 self.SetMinSize(self.ClientToWindowSize(minsize)) # client to window
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
294
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
295 self.cbuttons_reload()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
296
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
297 def gui_set_connected(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
298 self.xyb.enable()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
299 self.zb.enable()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
300 for control in self.printerControls:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
301 control.Enable()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
302
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
303 def gui_set_disconnected(self):
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
304 self.printbtn.Disable()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
305 self.pausebtn.Disable()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
306 self.recoverbtn.Disable()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
307 for control in self.printerControls:
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
308 control.Disable()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
309 self.xyb.disable()
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
310 self.zb.disable()

mercurial