31 |
33 |
32 class ToggleablePane(wx.BoxSizer): |
34 class ToggleablePane(wx.BoxSizer): |
33 |
35 |
34 def __init__(self, root, label, parentpanel, parentsizers): |
36 def __init__(self, root, label, parentpanel, parentsizers): |
35 super(ToggleablePane, self).__init__(wx.HORIZONTAL) |
37 super(ToggleablePane, self).__init__(wx.HORIZONTAL) |
36 if not parentpanel: parentpanel = root.panel |
38 if not parentpanel: |
|
39 parentpanel = root.panel |
37 self.root = root |
40 self.root = root |
38 self.visible = True |
41 self.visible = True |
39 self.parentpanel = parentpanel |
42 self.parentpanel = parentpanel |
40 self.parentsizers = parentsizers |
43 self.parentsizers = parentsizers |
41 self.panepanel = root.newPanel(parentpanel) |
44 self.panepanel = root.newPanel(parentpanel) |
42 self.button = wx.Button(parentpanel, -1, label, size = (22, 18), style = wx.BU_EXACTFIT) |
45 self.button = wx.Button(parentpanel, -1, label, size = (35, 18), style = wx.BU_EXACTFIT) |
43 self.button.Bind(wx.EVT_BUTTON, self.toggle) |
46 self.button.Bind(wx.EVT_BUTTON, self.toggle) |
44 |
47 |
45 def toggle(self, event): |
48 def toggle(self, event): |
46 if self.visible: |
49 if self.visible: |
47 self.Hide(self.panepanel) |
50 self.Hide(self.panepanel) |
52 self.visible = not self.visible |
55 self.visible = not self.visible |
53 self.button.SetLabel(">" if self.button.GetLabel() == "<" else "<") |
56 self.button.SetLabel(">" if self.button.GetLabel() == "<" else "<") |
54 |
57 |
55 class LeftPaneToggleable(ToggleablePane): |
58 class LeftPaneToggleable(ToggleablePane): |
56 def __init__(self, root, parentpanel, parentsizers): |
59 def __init__(self, root, parentpanel, parentsizers): |
57 super(LeftPaneToggleable, self).__init__(root, "<", parentpanel, parentsizers) |
60 super().__init__(root, "<", parentpanel, parentsizers) |
58 self.Add(self.panepanel, 0, wx.EXPAND) |
61 self.Add(self.panepanel, 0, wx.EXPAND) |
59 self.Add(self.button, 0) |
62 self.Add(self.button, 0) |
60 |
63 |
61 def set_sizer(self, sizer): |
64 def set_sizer(self, sizer): |
62 self.panepanel.SetSizer(sizer) |
65 self.panepanel.SetSizer(sizer) |
101 self.orig_min_size = self.splitter.GetMinimumPaneSize() |
105 self.orig_min_size = self.splitter.GetMinimumPaneSize() |
102 self.orig_gravity = self.splitter.GetSashGravity() |
106 self.orig_gravity = self.splitter.GetSashGravity() |
103 self.splitter.SetMinimumPaneSize(button_width) |
107 self.splitter.SetMinimumPaneSize(button_width) |
104 self.splitter.SetSashGravity(1) |
108 self.splitter.SetSashGravity(1) |
105 self.splitter.SetSashPosition(self.splitter.GetSize()[0] - button_width) |
109 self.splitter.SetSashPosition(self.splitter.GetSize()[0] - button_width) |
106 if hasattr(self.splitter, "SetSashSize"): |
110 if getattr(self.splitter, 'SetSashSize', False): |
107 self.orig_sash_size = self.splitter.GetSashSize() |
111 self.orig_sash_size = self.splitter.GetSashSize() |
108 self.splitter.SetSashSize(0) |
112 self.splitter.SetSashSize(0) |
109 if hasattr(self.splitter, "SetSashInvisible"): self.splitter.SetSashInvisible(True) |
113 getattr(self.splitter, 'SetSashInvisible', bool)(True) |
110 for sizer in self.parentsizers: |
114 for sizer in self.parentsizers: |
111 sizer.Layout() |
115 sizer.Layout() |
112 |
116 |
113 class MainWindow(wx.Frame): |
117 class MainWindow(wx.Frame): |
114 |
118 |
115 def __init__(self, *args, **kwargs): |
119 def __init__(self, *args, **kwargs): |
116 super(MainWindow, self).__init__(*args, **kwargs) |
120 super().__init__(*args, **kwargs) |
117 # this list will contain all controls that should be only enabled |
121 # this list will contain all controls that should be only enabled |
118 # when we're connected to a printer |
122 # when we're connected to a printer |
119 self.panel = wx.Panel(self, -1) |
123 self.panel = wx.Panel(self) |
120 self.reset_ui() |
124 self.reset_ui() |
121 self.statefulControls = [] |
125 self.statefulControls = [] |
122 |
126 |
123 def reset_ui(self): |
127 def reset_ui(self): |
124 self.panels = [] |
128 self.panels = [] |
197 self.registerPanel(page4panel) |
202 self.registerPanel(page4panel) |
198 self.notebook.AddPage(page3panel, _("Plater")) |
203 self.notebook.AddPage(page3panel, _("Plater")) |
199 self.notebook.AddPage(page4panel, _("G-Code Plater")) |
204 self.notebook.AddPage(page4panel, _("G-Code Plater")) |
200 self.panel.SetSizer(self.notesizer) |
205 self.panel.SetSizer(self.notesizer) |
201 self.panel.Bind(wx.EVT_MOUSE_EVENTS, self.editbutton) |
206 self.panel.Bind(wx.EVT_MOUSE_EVENTS, self.editbutton) |
202 self.Bind(wx.EVT_CLOSE, self.kill) |
|
203 |
207 |
204 # Custom buttons |
208 # Custom buttons |
205 if wx.VERSION > (2, 9): self.cbuttonssizer = wx.WrapSizer(wx.HORIZONTAL) |
209 self.cbuttonssizer = wx.WrapSizer(wx.HORIZONTAL) |
206 else: self.cbuttonssizer = wx.GridBagSizer() |
|
207 self.cbuttonssizer = wx.GridBagSizer() |
|
208 self.centerpanel = self.newPanel(page1panel2) |
210 self.centerpanel = self.newPanel(page1panel2) |
209 self.centerpanel.SetSizer(self.cbuttonssizer) |
211 self.centerpanel.SetSizer(self.cbuttonssizer) |
210 rightsizer.Add(self.centerpanel, 0, wx.ALIGN_CENTER) |
212 rightsizer.Add(self.centerpanel, 0, wx.ALIGN_CENTER) |
211 rightsizer.AddStretchSpacer() |
213 rightsizer.AddStretchSpacer() |
212 |
214 |
235 controls_panel.SetSizer(controls_sizer) |
237 controls_panel.SetSizer(controls_sizer) |
236 left_sizer = wx.BoxSizer(wx.VERTICAL) |
238 left_sizer = wx.BoxSizer(wx.VERTICAL) |
237 left_sizer.Add(controls_panel, 1, wx.EXPAND) |
239 left_sizer.Add(controls_panel, 1, wx.EXPAND) |
238 left_pane.set_sizer(left_sizer) |
240 left_pane.set_sizer(left_sizer) |
239 self.lowersizer.Add(leftpanel, 0, wx.EXPAND) |
241 self.lowersizer.Add(leftpanel, 0, wx.EXPAND) |
240 if not compact: # Use a splitterwindow to group viz and log |
242 if compact: |
|
243 vizpanel = self.newPanel(lowerpanel) |
|
244 logpanel = self.newPanel(left_real_panel) |
|
245 else: |
|
246 # Use a splitterwindow to group viz and log |
241 rightpanel = self.newPanel(lowerpanel) |
247 rightpanel = self.newPanel(lowerpanel) |
242 rightsizer = wx.BoxSizer(wx.VERTICAL) |
248 rightsizer = wx.BoxSizer(wx.VERTICAL) |
243 rightpanel.SetSizer(rightsizer) |
249 rightpanel.SetSizer(rightsizer) |
244 self.splitterwindow = wx.SplitterWindow(rightpanel, style = wx.SP_3D) |
250 self.splitterwindow = wx.SplitterWindow(rightpanel, style = wx.SP_3D | wx.SP_LIVE_UPDATE) |
245 self.splitterwindow.SetMinimumPaneSize(150) |
251 self.splitterwindow.SetMinimumPaneSize(150) |
246 self.splitterwindow.SetSashGravity(0.8) |
252 self.splitterwindow.SetSashGravity(0.8) |
247 rightsizer.Add(self.splitterwindow, 1, wx.EXPAND) |
253 rightsizer.Add(self.splitterwindow, 1, wx.EXPAND) |
248 vizpanel = self.newPanel(self.splitterwindow) |
254 vizpanel = self.newPanel(self.splitterwindow) |
249 logpanel = self.newPanel(self.splitterwindow) |
255 logpanel = self.newPanel(self.splitterwindow) |
250 self.splitterwindow.SplitVertically(vizpanel, logpanel, |
256 self.splitterwindow.SplitVertically(vizpanel, logpanel, |
251 self.settings.last_sash_position) |
257 self.settings.last_sash_position) |
252 self.splitterwindow.shrinked = False |
258 self.splitterwindow.shrinked = False |
253 else: |
|
254 vizpanel = self.newPanel(lowerpanel) |
|
255 logpanel = self.newPanel(left_real_panel) |
|
256 viz_pane = VizPane(self, vizpanel) |
259 viz_pane = VizPane(self, vizpanel) |
257 # Custom buttons |
260 # Custom buttons |
258 if wx.VERSION > (2, 9): self.cbuttonssizer = wx.WrapSizer(wx.HORIZONTAL) |
261 self.cbuttonssizer = wx.WrapSizer(wx.HORIZONTAL) |
259 else: self.cbuttonssizer = wx.GridBagSizer() |
|
260 self.centerpanel = self.newPanel(vizpanel) |
262 self.centerpanel = self.newPanel(vizpanel) |
261 self.centerpanel.SetSizer(self.cbuttonssizer) |
263 self.centerpanel.SetSizer(self.cbuttonssizer) |
262 viz_pane.Add(self.centerpanel, 0, flag = wx.ALIGN_CENTER) |
264 viz_pane.Add(self.centerpanel, 0, flag = wx.ALIGN_CENTER) |
263 vizpanel.SetSizer(viz_pane) |
265 vizpanel.SetSizer(viz_pane) |
264 if compact: |
266 if compact: |
265 log_pane = LogPane(self, logpanel) |
267 log_pane = LogPane(self, logpanel) |
266 else: |
268 else: |
267 log_pane = LogPaneToggleable(self, logpanel, [self.lowersizer]) |
269 log_pane = LogPaneToggleable(self, logpanel, [self.lowersizer]) |
268 left_pane.parentsizers.append(self.splitterwindow) |
270 left_pane.parentsizers.append(self.splitterwindow) |
269 logpanel.SetSizer(log_pane) |
271 logpanel.SetSizer(log_pane) |
270 if not compact: |
272 if compact: |
271 self.lowersizer.Add(rightpanel, 1, wx.EXPAND) |
|
272 else: |
|
273 left_sizer.Add(logpanel, 1, wx.EXPAND) |
273 left_sizer.Add(logpanel, 1, wx.EXPAND) |
274 self.lowersizer.Add(vizpanel, 1, wx.EXPAND) |
274 self.lowersizer.Add(vizpanel, 1, wx.EXPAND) |
|
275 else: |
|
276 self.lowersizer.Add(rightpanel, 1, wx.EXPAND) |
275 self.mainsizer.Add(upperpanel, 0, wx.EXPAND) |
277 self.mainsizer.Add(upperpanel, 0, wx.EXPAND) |
276 self.mainsizer.Add(lowerpanel, 1, wx.EXPAND) |
278 self.mainsizer.Add(lowerpanel, 1, wx.EXPAND) |
277 self.panel.SetSizer(self.mainsizer) |
279 self.panel.SetSizer(self.mainsizer) |
278 self.panel.Bind(wx.EVT_MOUSE_EVENTS, self.editbutton) |
280 self.panel.Bind(wx.EVT_MOUSE_EVENTS, self.editbutton) |
279 self.Bind(wx.EVT_CLOSE, self.kill) |
|
280 |
281 |
281 self.mainsizer.Layout() |
282 self.mainsizer.Layout() |
282 # This prevents resizing below a reasonnable value |
283 # This prevents resizing below a reasonnable value |
283 # We sum the lowersizer (left pane / viz / log) min size |
284 # We sum the lowersizer (left pane / viz / log) min size |
284 # the toolbar height and the statusbar/menubar sizes |
285 # the toolbar height and the statusbar/menubar sizes |