Commit c867ebaf authored by Guillaume Seguin's avatar Guillaume Seguin

Initial lock implementation (#400)

parent a85201bf
...@@ -345,9 +345,18 @@ class LogPane(wx.BoxSizer): ...@@ -345,9 +345,18 @@ class LogPane(wx.BoxSizer):
def MainToolbar(root, parentpanel = None, use_wrapsizer = False): def MainToolbar(root, parentpanel = None, use_wrapsizer = False):
if not parentpanel: parentpanel = root.panel
if root.settings.lockbox:
root.locker = wx.CheckBox(parentpanel, label = _("Lock") + " ")
root.locker.Bind(wx.EVT_CHECKBOX, root.lock)
root.locker.SetToolTip(wx.ToolTip(_("Lock graphical interface")))
glob = wx.BoxSizer(wx.HORIZONTAL)
origpanel = parentpanel
parentpanel = root.newPanel(parentpanel)
glob.Add(parentpanel, 1, flag = wx.EXPAND)
glob.Add(root.locker, 0)
ToolbarSizer = wx.WrapSizer if use_wrapsizer and wx.VERSION > (2, 9) else wx.BoxSizer ToolbarSizer = wx.WrapSizer if use_wrapsizer and wx.VERSION > (2, 9) else wx.BoxSizer
self = ToolbarSizer(wx.HORIZONTAL) self = ToolbarSizer(wx.HORIZONTAL)
if not parentpanel: parentpanel = root.panel
root.rescanbtn = make_sized_button(parentpanel, _("Port"), root.rescanports, _("Communication Settings\nClick to rescan ports")) root.rescanbtn = make_sized_button(parentpanel, _("Port"), root.rescanports, _("Communication Settings\nClick to rescan ports"))
self.Add(root.rescanbtn, 0, wx.TOP|wx.LEFT, 0) self.Add(root.rescanbtn, 0, wx.TOP|wx.LEFT, 0)
...@@ -380,6 +389,10 @@ def MainToolbar(root, parentpanel = None, use_wrapsizer = False): ...@@ -380,6 +389,10 @@ def MainToolbar(root, parentpanel = None, use_wrapsizer = False):
root.pausebtn = make_sized_button(parentpanel, _("Pause"), root.pause, _("Pause Current Print"), self) root.pausebtn = make_sized_button(parentpanel, _("Pause"), root.pause, _("Pause Current Print"), self)
root.offbtn = make_sized_button(parentpanel, _("Off"), root.off, _("Turn printer off"), self) root.offbtn = make_sized_button(parentpanel, _("Off"), root.off, _("Turn printer off"), self)
root.printerControls.append(root.offbtn) root.printerControls.append(root.offbtn)
if root.settings.lockbox:
parentpanel.SetSizer(self)
return glob
else:
return self return self
class MainWindow(wx.Frame): class MainWindow(wx.Frame):
...@@ -389,10 +402,13 @@ class MainWindow(wx.Frame): ...@@ -389,10 +402,13 @@ class MainWindow(wx.Frame):
# this list will contain all controls that should be only enabled # this list will contain all controls that should be only enabled
# when we're connected to a printer # when we're connected to a printer
self.printerControls = [] self.printerControls = []
self.panel = wx.Panel(self, -1, size = kwargs["size"])
self.panels = []
def newPanel(self, parent): def newPanel(self, parent, add_to_list = True):
panel = wx.Panel(parent) panel = wx.Panel(parent)
panel.SetBackgroundColour(self.settings.bgcolor) panel.SetBackgroundColour(self.settings.bgcolor)
if add_to_list: self.panels.append(panel)
return panel return panel
def createTabbedGui(self): def createTabbedGui(self):
...@@ -469,7 +485,7 @@ class MainWindow(wx.Frame): ...@@ -469,7 +485,7 @@ class MainWindow(wx.Frame):
def createGui(self, compact = False): def createGui(self, compact = False):
self.mainsizer = wx.BoxSizer(wx.VERTICAL) self.mainsizer = wx.BoxSizer(wx.VERTICAL)
self.lowersizer = wx.BoxSizer(wx.HORIZONTAL) self.lowersizer = wx.BoxSizer(wx.HORIZONTAL)
upperpanel = self.newPanel(self.panel) upperpanel = self.newPanel(self.panel, False)
self.uppersizer = MainToolbar(self, upperpanel) self.uppersizer = MainToolbar(self, upperpanel)
lowerpanel = self.newPanel(self.panel) lowerpanel = self.newPanel(self.panel)
upperpanel.SetSizer(self.uppersizer) upperpanel.SetSizer(self.uppersizer)
......
...@@ -199,6 +199,7 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -199,6 +199,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.settings._add(ComboSetting("mainviz", "2D", ["2D", "3D", "None"], _("Main visualization"), _("Select visualization for main window."), "UI")) self.settings._add(ComboSetting("mainviz", "2D", ["2D", "3D", "None"], _("Main visualization"), _("Select visualization for main window."), "UI"))
self.settings._add(BooleanSetting("tempgraph", True, _("Display temperature graph"), _("Display time-lapse temperature graph"), "UI")) self.settings._add(BooleanSetting("tempgraph", True, _("Display temperature graph"), _("Display time-lapse temperature graph"), "UI"))
self.settings._add(BooleanSetting("tempgauges", False, _("Display temperature gauges"), _("Display graphical gauges for temperatures visualization"), "UI")) self.settings._add(BooleanSetting("tempgauges", False, _("Display temperature gauges"), _("Display graphical gauges for temperatures visualization"), "UI"))
self.settings._add(BooleanSetting("lockbox", False, _("Display interface lock checkbox"), _("Display a checkbox that, when check, locks most of Pronterface"), "UI"))
self.settings._add(HiddenSetting("last_bed_temperature", 0.0)) self.settings._add(HiddenSetting("last_bed_temperature", 0.0))
self.settings._add(HiddenSetting("last_file_path", "")) self.settings._add(HiddenSetting("last_file_path", ""))
self.settings._add(HiddenSetting("last_temperature", 0.0)) self.settings._add(HiddenSetting("last_temperature", 0.0))
...@@ -217,7 +218,6 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -217,7 +218,6 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.SetIcon(wx.Icon(sys.executable, wx.BITMAP_TYPE_ICO)) self.SetIcon(wx.Icon(sys.executable, wx.BITMAP_TYPE_ICO))
else: else:
self.SetIcon(wx.Icon(pixmapfile("P-face.ico"), wx.BITMAP_TYPE_ICO)) self.SetIcon(wx.Icon(pixmapfile("P-face.ico"), wx.BITMAP_TYPE_ICO))
self.panel = wx.Panel(self,-1, size = size)
self.statuscheck = False self.statuscheck = False
self.status_thread = None self.status_thread = None
...@@ -1745,6 +1745,16 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -1745,6 +1745,16 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.paused = 0 self.paused = 0
dlg.Destroy() dlg.Destroy()
def lock(self, event):
if self.locker.GetValue():
print _("Locking interface.")
for panel in self.panels:
panel.Disable()
else:
print _("Unlocking interface.")
for panel in self.panels:
panel.Enable()
class PronterApp(wx.App): class PronterApp(wx.App):
mainwindow = None mainwindow = None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment