Commit 38d63f7d authored by Guillaume Seguin's avatar Guillaume Seguin

First attempt at a tabbed GUI

parent 7064f906
...@@ -46,88 +46,59 @@ def make_autosize_button(*args): ...@@ -46,88 +46,59 @@ def make_autosize_button(*args):
class XYZControlsSizer(wx.GridBagSizer): class XYZControlsSizer(wx.GridBagSizer):
def __init__(self, root): def __init__(self, root, parentpanel = None):
super(XYZControlsSizer, self).__init__() super(XYZControlsSizer, self).__init__()
root.xyb = XYButtons(root.panel, root.moveXY, root.homeButtonClicked, root.spacebarAction, root.settings.bgcolor, zcallback=root.moveZ) if not parentpanel: parentpanel = root.panel
root.xyb = XYButtons(parentpanel, root.moveXY, root.homeButtonClicked, root.spacebarAction, root.settings.bgcolor, zcallback=root.moveZ)
self.Add(root.xyb, pos = (0, 1), flag = wx.ALIGN_CENTER) self.Add(root.xyb, pos = (0, 1), flag = wx.ALIGN_CENTER)
root.zb = ZButtons(root.panel, root.moveZ, root.settings.bgcolor) root.zb = ZButtons(parentpanel, root.moveZ, root.settings.bgcolor)
self.Add(root.zb, pos = (0, 2), flag = wx.ALIGN_CENTER) self.Add(root.zb, pos = (0, 2), flag = wx.ALIGN_CENTER)
wx.CallAfter(root.xyb.SetFocus) wx.CallAfter(root.xyb.SetFocus)
class LeftPane(wx.GridBagSizer): def add_extra_controls(self, root, parentpanel, base_line):
root.monitorbox = wx.CheckBox(parentpanel,-1, _("Watch"))
def __init__(self, root):
super(LeftPane, self).__init__()
llts = wx.BoxSizer(wx.HORIZONTAL)
self.Add(llts, pos = (0, 0), span = (1, 6))
self.xyzsizer = XYZControlsSizer(root)
self.Add(self.xyzsizer, pos = (1, 0), span = (1, 6), flag = wx.ALIGN_CENTER)
for i in root.cpbuttons:
btn = make_button(root.panel, i.label, root.procbutton, i.tooltip)
btn.SetBackgroundColour(i.background)
btn.SetForegroundColour("black")
btn.properties = i
root.btndict[i.command] = btn
root.printerControls.append(btn)
if i.pos == None:
if i.span == 0:
llts.Add(btn)
else:
self.Add(btn, pos = i.pos, span = i.span, flag = wx.EXPAND)
root.xyfeedc = wx.SpinCtrl(root.panel,-1, str(root.settings.xy_feedrate), min = 0, max = 50000, size = (70,-1))
root.xyfeedc.SetToolTip(wx.ToolTip("Set Maximum Speed for X & Y axes (mm/min)"))
llts.Add(wx.StaticText(root.panel,-1, _("XY:")), flag = wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
llts.Add(root.xyfeedc)
llts.Add(wx.StaticText(root.panel,-1, _("mm/min Z:")), flag = wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
root.zfeedc = wx.SpinCtrl(root.panel,-1, str(root.settings.z_feedrate), min = 0, max = 50000, size = (70,-1))
root.zfeedc.SetToolTip(wx.ToolTip("Set Maximum Speed for Z axis (mm/min)"))
llts.Add(root.zfeedc,)
root.monitorbox = wx.CheckBox(root.panel,-1, _("Watch"))
root.monitorbox.SetValue(bool(root.settings.monitor)) root.monitorbox.SetValue(bool(root.settings.monitor))
root.monitorbox.SetToolTip(wx.ToolTip("Monitor Temperatures in Graph")) root.monitorbox.SetToolTip(wx.ToolTip("Monitor Temperatures in Graph"))
self.Add(root.monitorbox, pos = (3, 5)) self.Add(root.monitorbox, pos = (base_line + 1, 5))
root.monitorbox.Bind(wx.EVT_CHECKBOX, root.setmonitor) root.monitorbox.Bind(wx.EVT_CHECKBOX, root.setmonitor)
self.Add(wx.StaticText(root.panel,-1, _("Heat:")), pos = (2, 0), span = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT) self.Add(wx.StaticText(parentpanel,-1, _("Heat:")), pos = (base_line + 0, 0), span = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
htemp_choices = [root.temps[i]+" ("+i+")" for i in sorted(root.temps.keys(), key = lambda x:root.temps[x])] htemp_choices = [root.temps[i]+" ("+i+")" for i in sorted(root.temps.keys(), key = lambda x:root.temps[x])]
root.settoff = make_button(root.panel, _("Off"), lambda e: root.do_settemp("off"), _("Switch Hotend Off"), size = (36,-1), style = wx.BU_EXACTFIT) root.settoff = make_button(parentpanel, _("Off"), lambda e: root.do_settemp("off"), _("Switch Hotend Off"), size = (36,-1), style = wx.BU_EXACTFIT)
root.printerControls.append(root.settoff) root.printerControls.append(root.settoff)
self.Add(root.settoff, pos = (2, 1), span = (1, 1)) self.Add(root.settoff, pos = (base_line + 0, 1), span = (1, 1))
if root.settings.last_temperature not in map(float, root.temps.values()): if root.settings.last_temperature not in map(float, root.temps.values()):
htemp_choices = [str(root.settings.last_temperature)] + htemp_choices htemp_choices = [str(root.settings.last_temperature)] + htemp_choices
root.htemp = wx.ComboBox(root.panel, -1, root.htemp = wx.ComboBox(parentpanel, -1,
choices = htemp_choices, style = wx.CB_DROPDOWN, size = (80,-1)) choices = htemp_choices, style = wx.CB_DROPDOWN, size = (80,-1))
root.htemp.SetToolTip(wx.ToolTip("Select Temperature for Hotend")) root.htemp.SetToolTip(wx.ToolTip("Select Temperature for Hotend"))
root.htemp.Bind(wx.EVT_COMBOBOX, root.htemp_change) root.htemp.Bind(wx.EVT_COMBOBOX, root.htemp_change)
self.Add(root.htemp, pos = (2, 2), span = (1, 2)) self.Add(root.htemp, pos = (base_line + 0, 2), span = (1, 2))
root.settbtn = make_button(root.panel, _("Set"), root.do_settemp, _("Switch Hotend On"), size = (38, -1), style = wx.BU_EXACTFIT) root.settbtn = make_button(parentpanel, _("Set"), root.do_settemp, _("Switch Hotend On"), size = (38, -1), style = wx.BU_EXACTFIT)
root.printerControls.append(root.settbtn) root.printerControls.append(root.settbtn)
self.Add(root.settbtn, pos = (2, 4), span = (1, 1)) self.Add(root.settbtn, pos = (base_line + 0, 4), span = (1, 1))
self.Add(wx.StaticText(root.panel,-1, _("Bed:")), pos = (3, 0), span = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT) self.Add(wx.StaticText(parentpanel,-1, _("Bed:")), pos = (base_line + 1, 0), span = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
btemp_choices = [root.bedtemps[i]+" ("+i+")" for i in sorted(root.bedtemps.keys(), key = lambda x:root.temps[x])] btemp_choices = [root.bedtemps[i]+" ("+i+")" for i in sorted(root.bedtemps.keys(), key = lambda x:root.temps[x])]
root.setboff = make_button(root.panel, _("Off"), lambda e:root.do_bedtemp("off"), _("Switch Heated Bed Off"), size = (36,-1), style = wx.BU_EXACTFIT) root.setboff = make_button(parentpanel, _("Off"), lambda e:root.do_bedtemp("off"), _("Switch Heated Bed Off"), size = (36,-1), style = wx.BU_EXACTFIT)
root.printerControls.append(root.setboff) root.printerControls.append(root.setboff)
self.Add(root.setboff, pos = (3, 1), span = (1, 1)) self.Add(root.setboff, pos = (base_line + 1, 1), span = (1, 1))
if root.settings.last_bed_temperature not in map(float, root.bedtemps.values()): if root.settings.last_bed_temperature not in map(float, root.bedtemps.values()):
btemp_choices = [str(root.settings.last_bed_temperature)] + btemp_choices btemp_choices = [str(root.settings.last_bed_temperature)] + btemp_choices
root.btemp = wx.ComboBox(root.panel, -1, root.btemp = wx.ComboBox(parentpanel, -1,
choices = btemp_choices, style = wx.CB_DROPDOWN, size = (80,-1)) choices = btemp_choices, style = wx.CB_DROPDOWN, size = (80,-1))
root.btemp.SetToolTip(wx.ToolTip("Select Temperature for Heated Bed")) root.btemp.SetToolTip(wx.ToolTip("Select Temperature for Heated Bed"))
root.btemp.Bind(wx.EVT_COMBOBOX, root.btemp_change) root.btemp.Bind(wx.EVT_COMBOBOX, root.btemp_change)
self.Add(root.btemp, pos = (3, 2), span = (1, 2)) self.Add(root.btemp, pos = (base_line + 1, 2), span = (1, 2))
root.setbbtn = make_button(root.panel, _("Set"), root.do_bedtemp, ("Switch Heated Bed On"), size = (38, -1), style = wx.BU_EXACTFIT) root.setbbtn = make_button(parentpanel, _("Set"), root.do_bedtemp, ("Switch Heated Bed On"), size = (38, -1), style = wx.BU_EXACTFIT)
root.printerControls.append(root.setbbtn) root.printerControls.append(root.setbbtn)
self.Add(root.setbbtn, pos = (3, 4), span = (1, 1)) self.Add(root.setbbtn, pos = (base_line + 1, 4), span = (1, 1))
root.btemp.SetValue(str(root.settings.last_bed_temperature)) root.btemp.SetValue(str(root.settings.last_bed_temperature))
root.htemp.SetValue(str(root.settings.last_temperature)) root.htemp.SetValue(str(root.settings.last_temperature))
...@@ -148,34 +119,28 @@ class LeftPane(wx.GridBagSizer): ...@@ -148,34 +119,28 @@ class LeftPane(wx.GridBagSizer):
if( '(' not in root.htemp.Value): if( '(' not in root.htemp.Value):
root.htemp.SetValue(root.htemp.Value + ' (user)') root.htemp.SetValue(root.htemp.Value + ' (user)')
root.tempdisp = wx.StaticText(root.panel,-1, "") root.tempdisp = wx.StaticText(parentpanel,-1, "")
root.edist = wx.SpinCtrl(root.panel,-1, "5", min = 0, max = 1000, size = (70,-1)) root.edist = wx.SpinCtrl(parentpanel,-1, "5", min = 0, max = 1000, size = (70,-1))
root.edist.SetBackgroundColour((225, 200, 200)) root.edist.SetBackgroundColour((225, 200, 200))
root.edist.SetForegroundColour("black") root.edist.SetForegroundColour("black")
self.Add(root.edist, pos = (4, 2), span = (1, 2), flag = wx.EXPAND | wx.RIGHT, border = 10) self.Add(root.edist, pos = (base_line + 2, 2), span = (1, 2), flag = wx.EXPAND | wx.RIGHT, border = 10)
self.Add(wx.StaticText(root.panel,-1, _("mm")), pos = (4, 4), span = (1, 1)) self.Add(wx.StaticText(parentpanel,-1, _("mm")), pos = (base_line + 2, 4), span = (1, 1))
root.edist.SetToolTip(wx.ToolTip("Amount to Extrude or Retract (mm)")) root.edist.SetToolTip(wx.ToolTip("Amount to Extrude or Retract (mm)"))
root.efeedc = wx.SpinCtrl(root.panel,-1, str(root.settings.e_feedrate), min = 0, max = 50000, size = (70,-1)) root.efeedc = wx.SpinCtrl(parentpanel,-1, str(root.settings.e_feedrate), min = 0, max = 50000, size = (70,-1))
root.efeedc.SetToolTip(wx.ToolTip("Extrude / Retract speed (mm/min)")) root.efeedc.SetToolTip(wx.ToolTip("Extrude / Retract speed (mm/min)"))
root.efeedc.SetBackgroundColour((225, 200, 200)) root.efeedc.SetBackgroundColour((225, 200, 200))
root.efeedc.SetForegroundColour("black") root.efeedc.SetForegroundColour("black")
root.efeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds) root.efeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds)
root.efeedc.Bind(wx.EVT_TEXT, root.setfeeds) root.efeedc.Bind(wx.EVT_TEXT, root.setfeeds)
self.Add(root.efeedc, pos = (5, 2), span = (1, 2), flag = wx.EXPAND | wx.RIGHT, border = 10) self.Add(root.efeedc, pos = (base_line + 3, 2), span = (1, 2), flag = wx.EXPAND | wx.RIGHT, border = 10)
self.Add(wx.StaticText(root.panel,-1, _("mm/\nmin")), pos = (5, 4), span = (2, 1)) self.Add(wx.StaticText(parentpanel,-1, _("mm/\nmin")), pos = (base_line + 3, 4), span = (2, 1))
root.xyfeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds)
root.zfeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds)
root.xyfeedc.Bind(wx.EVT_TEXT, root.setfeeds)
root.zfeedc.Bind(wx.EVT_TEXT, root.setfeeds)
root.zfeedc.SetBackgroundColour((180, 255, 180))
root.zfeedc.SetForegroundColour("black")
if root.display_gauges: if root.display_gauges:
root.hottgauge = TempGauge(root.panel, size = (-1, 24), title = _("Heater:"), maxval = 300) root.hottgauge = TempGauge(parentpanel, size = (-1, 24), title = _("Heater:"), maxval = 300)
self.Add(root.hottgauge, pos = (7, 0), span = (1, 6), flag = wx.EXPAND) self.Add(root.hottgauge, pos = (base_line + 5, 0), span = (1, 6), flag = wx.EXPAND)
root.bedtgauge = TempGauge(root.panel, size = (-1, 24), title = _("Bed:"), maxval = 150) root.bedtgauge = TempGauge(parentpanel, size = (-1, 24), title = _("Bed:"), maxval = 150)
self.Add(root.bedtgauge, pos = (8, 0), span = (1, 6), flag = wx.EXPAND) self.Add(root.bedtgauge, pos = (base_line + 6, 0), span = (1, 6), flag = wx.EXPAND)
def hotendgauge_scroll_setpoint(e): def hotendgauge_scroll_setpoint(e):
rot = e.GetWheelRotation() rot = e.GetWheelRotation()
if rot > 0: if rot > 0:
...@@ -190,12 +155,58 @@ class LeftPane(wx.GridBagSizer): ...@@ -190,12 +155,58 @@ class LeftPane(wx.GridBagSizer):
root.do_settemp(str(max(0, root.bsetpoint - 1))) root.do_settemp(str(max(0, root.bsetpoint - 1)))
root.hottgauge.Bind(wx.EVT_MOUSEWHEEL, hotendgauge_scroll_setpoint) root.hottgauge.Bind(wx.EVT_MOUSEWHEEL, hotendgauge_scroll_setpoint)
root.bedtgauge.Bind(wx.EVT_MOUSEWHEEL, bedgauge_scroll_setpoint) root.bedtgauge.Bind(wx.EVT_MOUSEWHEEL, bedgauge_scroll_setpoint)
self.Add(root.tempdisp, pos = (9, 0), span = (1, 6)) self.Add(root.tempdisp, pos = (base_line + 7, 0), span = (1, 6))
else:
self.Add(root.tempdisp, pos = (base_line + 5, 0), span = (1, 6))
root.graph = Graph(parentpanel, wx.ID_ANY, root)
self.Add(root.graph, pos = (base_line + 2, 5), span = (3, 1))
class LeftPane(wx.GridBagSizer):
extra_base_line = 2
def __init__(self, root, parentpanel = None, extra_controls = None):
super(LeftPane, self).__init__()
if not parentpanel: parentpanel = root.panel
llts = wx.BoxSizer(wx.HORIZONTAL)
self.Add(llts, pos = (0, 0), span = (1, 6))
self.xyzsizer = XYZControlsSizer(root, parentpanel)
self.Add(self.xyzsizer, pos = (1, 0), span = (1, 6), flag = wx.ALIGN_CENTER)
for i in root.cpbuttons:
btn = make_button(parentpanel, i.label, root.procbutton, i.tooltip)
btn.SetBackgroundColour(i.background)
btn.SetForegroundColour("black")
btn.properties = i
root.btndict[i.command] = btn
root.printerControls.append(btn)
if i.pos == None:
if i.span == 0:
llts.Add(btn)
elif not extra_controls:
self.Add(btn, pos = i.pos, span = i.span, flag = wx.EXPAND)
else: else:
self.Add(root.tempdisp, pos = (7, 0), span = (1, 6)) extra_controls.Add(btn, pos = (i.pos[0] - self.extra_base_line, i.pos[1]), span = i.span, flag = wx.EXPAND)
root.graph = Graph(root.panel, wx.ID_ANY, root) root.xyfeedc = wx.SpinCtrl(parentpanel,-1, str(root.settings.xy_feedrate), min = 0, max = 50000, size = (70,-1))
self.Add(root.graph, pos = (4, 5), span = (3, 1)) root.xyfeedc.SetToolTip(wx.ToolTip("Set Maximum Speed for X & Y axes (mm/min)"))
llts.Add(wx.StaticText(parentpanel,-1, _("XY:")), flag = wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
llts.Add(root.xyfeedc)
llts.Add(wx.StaticText(parentpanel,-1, _("mm/min Z:")), flag = wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
root.zfeedc = wx.SpinCtrl(parentpanel,-1, str(root.settings.z_feedrate), min = 0, max = 50000, size = (70,-1))
root.zfeedc.SetToolTip(wx.ToolTip("Set Maximum Speed for Z axis (mm/min)"))
llts.Add(root.zfeedc,)
root.xyfeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds)
root.zfeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds)
root.xyfeedc.Bind(wx.EVT_TEXT, root.setfeeds)
root.zfeedc.Bind(wx.EVT_TEXT, root.setfeeds)
root.zfeedc.SetBackgroundColour((180, 255, 180))
root.zfeedc.SetForegroundColour("black")
if not extra_controls:
add_extra_controls(self, root, parentpanel, self.extra_base_line)
class NoViz(object): class NoViz(object):
...@@ -214,15 +225,16 @@ class NoViz(object): ...@@ -214,15 +225,16 @@ class NoViz(object):
class VizPane(wx.BoxSizer): class VizPane(wx.BoxSizer):
def __init__(self, root): def __init__(self, root, parentpanel = None):
super(VizPane, self).__init__(wx.VERTICAL) super(VizPane, self).__init__(wx.VERTICAL)
if not parentpanel: parentpanel = root.panel
if root.settings.mainviz == "None": if root.settings.mainviz == "None":
root.gviz = NoViz() root.gviz = NoViz()
use2dview = root.settings.mainviz == "2D" use2dview = root.settings.mainviz == "2D"
if root.settings.mainviz == "3D": if root.settings.mainviz == "3D":
try: try:
import printrun.gcview import printrun.gcview
root.gviz = printrun.gcview.GcodeViewMainWrapper(root.panel, root.build_dimensions_list) root.gviz = printrun.gcview.GcodeViewMainWrapper(parentpanel, root.build_dimensions_list)
root.gviz.clickcb = root.showwin root.gviz.clickcb = root.showwin
except: except:
use2dview = True use2dview = True
...@@ -230,7 +242,7 @@ class VizPane(wx.BoxSizer): ...@@ -230,7 +242,7 @@ class VizPane(wx.BoxSizer):
print "Falling back to 2D view, and here is the backtrace:" print "Falling back to 2D view, and here is the backtrace:"
traceback.print_exc() traceback.print_exc()
if use2dview: if use2dview:
root.gviz = gviz.gviz(root.panel, (300, 300), root.gviz = gviz.gviz(parentpanel, (300, 300),
build_dimensions = root.build_dimensions_list, build_dimensions = root.build_dimensions_list,
grid = (root.settings.preview_grid_step1, root.settings.preview_grid_step2), grid = (root.settings.preview_grid_step1, root.settings.preview_grid_step2),
extrusion_width = root.settings.preview_extrusion_width) extrusion_width = root.settings.preview_extrusion_width)
...@@ -263,15 +275,15 @@ class VizPane(wx.BoxSizer): ...@@ -263,15 +275,15 @@ class VizPane(wx.BoxSizer):
class LogPane(wx.BoxSizer): class LogPane(wx.BoxSizer):
def __init__(self, root): def __init__(self, root, parentpanel = None):
super(LogPane, self).__init__(wx.VERTICAL) super(LogPane, self).__init__(wx.VERTICAL)
root.lowerrsizer = self if not parentpanel: parentpanel = root.panel
root.logbox = wx.TextCtrl(root.panel, style = wx.TE_MULTILINE, size = (350,-1)) root.logbox = wx.TextCtrl(parentpanel, style = wx.TE_MULTILINE, size = (350,-1))
root.logbox.SetMinSize((100,-1)) root.logbox.SetMinSize((100,-1))
root.logbox.SetEditable(0) root.logbox.SetEditable(0)
self.Add(root.logbox, 1, wx.EXPAND) self.Add(root.logbox, 1, wx.EXPAND)
lbrs = wx.BoxSizer(wx.HORIZONTAL) lbrs = wx.BoxSizer(wx.HORIZONTAL)
root.commandbox = wx.TextCtrl(root.panel, style = wx.TE_PROCESS_ENTER) root.commandbox = wx.TextCtrl(parentpanel, style = wx.TE_PROCESS_ENTER)
root.commandbox.SetToolTip(wx.ToolTip("Send commands to printer\n(Type 'help' for simple\nhelp function)")) root.commandbox.SetToolTip(wx.ToolTip("Send commands to printer\n(Type 'help' for simple\nhelp function)"))
root.commandbox.Bind(wx.EVT_TEXT_ENTER, root.sendline) root.commandbox.Bind(wx.EVT_TEXT_ENTER, root.sendline)
root.commandbox.Bind(wx.EVT_CHAR, root.cbkey) root.commandbox.Bind(wx.EVT_CHAR, root.cbkey)
...@@ -279,26 +291,29 @@ class LogPane(wx.BoxSizer): ...@@ -279,26 +291,29 @@ class LogPane(wx.BoxSizer):
root.commandbox.histindex = 1 root.commandbox.histindex = 1
#root.printerControls.append(root.commandbox) #root.printerControls.append(root.commandbox)
lbrs.Add(root.commandbox, 1) lbrs.Add(root.commandbox, 1)
root.sendbtn = make_button(root.panel, _("Send"), root.sendline, _("Send Command to Printer"), style = wx.BU_EXACTFIT, container = lbrs) root.sendbtn = make_button(parentpanel, _("Send"), root.sendline, _("Send Command to Printer"), style = wx.BU_EXACTFIT, container = lbrs)
#root.printerControls.append(root.sendbtn) #root.printerControls.append(root.sendbtn)
self.Add(lbrs, 0, wx.EXPAND) self.Add(lbrs, 0, wx.EXPAND)
class MainToolbar(wx.BoxSizer): ToolbarSizer = wx.WrapSizer if wx.VERSION > (2, 9) else wx.BoxSizer
class MainToolbar(ToolbarSizer):
def __init__(self, root): def __init__(self, root, parentpanel = None):
super(MainToolbar, self).__init__(wx.HORIZONTAL) super(MainToolbar, self).__init__(wx.HORIZONTAL)
root.rescanbtn = make_sized_button(root.panel, _("Port"), root.rescanports, _("Communication Settings\nClick to rescan ports")) if not parentpanel: parentpanel = root.panel
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)
root.serialport = wx.ComboBox(root.panel, -1, root.serialport = wx.ComboBox(parentpanel, -1,
choices = root.scanserial(), choices = root.scanserial(),
style = wx.CB_DROPDOWN, size = (-1, 25)) style = wx.CB_DROPDOWN, size = (-1, 25))
root.serialport.SetToolTip(wx.ToolTip("Select Port Printer is connected to")) root.serialport.SetToolTip(wx.ToolTip("Select Port Printer is connected to"))
root.rescanports() root.rescanports()
self.Add(root.serialport) self.Add(root.serialport)
self.Add(wx.StaticText(root.panel,-1, "@"), 0, wx.RIGHT|wx.ALIGN_CENTER, 0) self.Add(wx.StaticText(parentpanel,-1, "@"), 0, wx.RIGHT|wx.ALIGN_CENTER, 0)
root.baud = wx.ComboBox(root.panel, -1, root.baud = wx.ComboBox(parentpanel, -1,
choices = ["2400", "9600", "19200", "38400", "57600", "115200", "250000"], choices = ["2400", "9600", "19200", "38400", "57600", "115200", "250000"],
style = wx.CB_DROPDOWN, size = (100, 25)) style = wx.CB_DROPDOWN, size = (100, 25))
root.baud.SetToolTip(wx.ToolTip("Select Baud rate for printer communication")) root.baud.SetToolTip(wx.ToolTip("Select Baud rate for printer communication"))
...@@ -308,17 +323,17 @@ class MainToolbar(wx.BoxSizer): ...@@ -308,17 +323,17 @@ class MainToolbar(wx.BoxSizer):
except: except:
pass pass
self.Add(root.baud) self.Add(root.baud)
root.connectbtn = make_sized_button(root.panel, _("Connect"), root.connect, _("Connect to the printer"), self) root.connectbtn = make_sized_button(parentpanel, _("Connect"), root.connect, _("Connect to the printer"), self)
root.resetbtn = make_autosize_button(root.panel, _("Reset"), root.reset, _("Reset the printer"), self) root.resetbtn = make_autosize_button(parentpanel, _("Reset"), root.reset, _("Reset the printer"), self)
root.loadbtn = make_autosize_button(root.panel, _("Load file"), root.loadfile, _("Load a 3D model file"), self) root.loadbtn = make_autosize_button(parentpanel, _("Load file"), root.loadfile, _("Load a 3D model file"), self)
root.platebtn = make_autosize_button(root.panel, _("Compose"), root.plate, _("Simple Plater System"), self) root.platebtn = make_autosize_button(parentpanel, _("Compose"), root.plate, _("Simple Plater System"), self)
root.sdbtn = make_autosize_button(root.panel, _("SD"), root.sdmenu, _("SD Card Printing"), self) root.sdbtn = make_autosize_button(parentpanel, _("SD"), root.sdmenu, _("SD Card Printing"), self)
root.printerControls.append(root.sdbtn) root.printerControls.append(root.sdbtn)
root.printbtn = make_sized_button(root.panel, _("Print"), root.printfile, _("Start Printing Loaded File"), self) root.printbtn = make_sized_button(parentpanel, _("Print"), root.printfile, _("Start Printing Loaded File"), self)
root.printbtn.Disable() root.printbtn.Disable()
root.pausebtn = make_sized_button(root.panel, _("Pause"), root.pause, _("Pause Current Print"), self) root.pausebtn = make_sized_button(parentpanel, _("Pause"), root.pause, _("Pause Current Print"), self)
root.recoverbtn = make_sized_button(root.panel, _("Recover"), root.recover, _("Recover previous Print"), self) root.recoverbtn = make_sized_button(parentpanel, _("Recover"), root.recover, _("Recover previous Print"), self)
class MainWindow(wx.Frame): class MainWindow(wx.Frame):
...@@ -328,6 +343,74 @@ class MainWindow(wx.Frame): ...@@ -328,6 +343,74 @@ class MainWindow(wx.Frame):
# when we're connected to a printer # when we're connected to a printer
self.printerControls = [] self.printerControls = []
def newPanel(self, parent):
panel = wx.Panel(parent)
panel.SetBackgroundColour(self.settings.bgcolor)
return panel
def createTabbedGui(self):
self.notesizer = wx.BoxSizer(wx.VERTICAL)
self.notebook = wx.Notebook(self.panel)
self.notebook.SetBackgroundColour(self.settings.bgcolor)
page1panel = self.newPanel(self.notebook)
page2panel = self.newPanel(self.notebook)
self.mainsizer_page1 = wx.BoxSizer(wx.VERTICAL)
page1panel1 = self.newPanel(page1panel)
page1panel2 = self.newPanel(page1panel)
self.uppersizer = MainToolbar(self, page1panel1)
page1panel1.SetSizer(self.uppersizer)
self.mainsizer_page1.Add(page1panel1, 0, wx.EXPAND)
self.lowersizer = wx.BoxSizer(wx.HORIZONTAL)
page1panel2.SetSizer(self.lowersizer)
extracontrols = wx.GridBagSizer()
add_extra_controls(extracontrols, self, page1panel2, 0)
leftsizer = wx.BoxSizer(wx.VERTICAL)
leftsizer.Add(LeftPane(self, page1panel2, extracontrols), 1, wx.ALIGN_CENTER)
rightsizer = wx.BoxSizer(wx.VERTICAL)
rightsizer.Add(extracontrols, 1, wx.ALIGN_CENTER)
self.lowersizer.Add(leftsizer, 1, wx.ALIGN_CENTER)
self.lowersizer.Add(rightsizer, 1, wx.ALIGN_CENTER)
self.mainsizer_page1.Add(page1panel2, 1, wx.EXPAND)
self.mainsizer = wx.BoxSizer(wx.HORIZONTAL)
self.splitterwindow = wx.SplitterWindow(page2panel, style = wx.SP_3D)
page2sizer1 = wx.BoxSizer(wx.HORIZONTAL)
page2panel1 = self.newPanel(self.splitterwindow)
page2sizer2 = wx.BoxSizer(wx.HORIZONTAL)
page2panel2 = self.newPanel(self.splitterwindow)
vizpane = VizPane(self, page2panel1)
page2sizer1.Add(vizpane, 1, wx.EXPAND)
page2sizer2.Add(LogPane(self, page2panel2), 1, wx.EXPAND)
page2panel1.SetSizer(page2sizer1)
page2panel2.SetSizer(page2sizer2)
self.splitterwindow.SetSashGravity(0.5)
self.splitterwindow.SplitVertically(page2panel1, page2panel2, 0)
self.mainsizer.Add(self.splitterwindow, 1, wx.EXPAND)
page1panel.SetSizer(self.mainsizer_page1)
page2panel.SetSizer(self.mainsizer)
self.notesizer.Add(self.notebook, 1, wx.EXPAND)
self.notebook.AddPage(page1panel, _("Commands"))
self.notebook.AddPage(page2panel, _("Status"))
self.panel.SetSizer(self.notesizer)
self.status = self.CreateStatusBar()
self.status.SetStatusText(_("Not connected to printer."))
self.panel.Bind(wx.EVT_MOUSE_EVENTS, self.editbutton)
self.Bind(wx.EVT_CLOSE, self.kill)
vizpane.Detach(self.centersizer)
rightsizer.Add(self.centersizer, 0, wx.EXPAND)
self.panel.SetSizerAndFit(self.notesizer)
# disable all printer controls until we connect to a printer
self.pausebtn.Disable()
self.recoverbtn.Disable()
for i in self.printerControls:
i.Disable()
#self.panel.Fit()
self.cbuttons_panel = page1panel
self.cbuttons_reload()
def createGui(self): def createGui(self):
self.mainsizer = wx.BoxSizer(wx.VERTICAL) self.mainsizer = wx.BoxSizer(wx.VERTICAL)
self.uppersizer = MainToolbar(self) self.uppersizer = MainToolbar(self)
...@@ -359,4 +442,4 @@ class MainWindow(wx.Frame): ...@@ -359,4 +442,4 @@ class MainWindow(wx.Frame):
i.Disable() i.Disable()
#self.panel.Fit() #self.panel.Fit()
self.cbuttons_reload() self.cbuttons_panel = self.panel
...@@ -191,6 +191,7 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -191,6 +191,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.settings._add(SpinSetting("preview_grid_step1", 10., 0, 200, _("Fine grid spacing"), _("Fine Grid Spacing (default: 10)"))) self.settings._add(SpinSetting("preview_grid_step1", 10., 0, 200, _("Fine grid spacing"), _("Fine Grid Spacing (default: 10)")))
self.settings._add(SpinSetting("preview_grid_step2", 50., 0, 200, _("Coarse grid spacing"), _("Coarse Grid Spacing (default: 50)"))) self.settings._add(SpinSetting("preview_grid_step2", 50., 0, 200, _("Coarse grid spacing"), _("Coarse Grid Spacing (default: 50)")))
self.settings._add(StringSetting("bgcolor", "#FFFFFF", _("Background color"), _("Pronterface background color (default: #FFFFFF)"))) self.settings._add(StringSetting("bgcolor", "#FFFFFF", _("Background color"), _("Pronterface background color (default: #FFFFFF)")))
self.settings._add(BooleanSetting("tabbed", False, _("Use tabbed interface"), _("Use tabbed interface instead of the single window one")))
self.pauseScript = "pause.gcode" self.pauseScript = "pause.gcode"
self.endScript = "end.gcode" self.endScript = "end.gcode"
...@@ -274,6 +275,9 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -274,6 +275,9 @@ class PronterWindow(MainWindow, pronsole.pronsole):
except: except:
pass pass
self.popmenu() self.popmenu()
if self.settings.tabbed:
self.createTabbedGui()
else:
self.createGui() self.createGui()
self.t = Tee(self.catchprint) self.t = Tee(self.catchprint)
self.stdout = sys.stdout self.stdout = sys.stdout
...@@ -740,7 +744,7 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -740,7 +744,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
for i in xrange(len(self.custombuttons)): for i in xrange(len(self.custombuttons)):
btndef = self.custombuttons[i] btndef = self.custombuttons[i]
try: try:
b = wx.Button(self.panel, -1, btndef.label, style = wx.BU_EXACTFIT) b = wx.Button(self.cbuttons_panel, -1, btndef.label, style = wx.BU_EXACTFIT)
b.SetToolTip(wx.ToolTip(_("Execute command: ")+btndef.command)) b.SetToolTip(wx.ToolTip(_("Execute command: ")+btndef.command))
if btndef.background: if btndef.background:
b.SetBackgroundColour(btndef.background) b.SetBackgroundColour(btndef.background)
...@@ -749,13 +753,13 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -749,13 +753,13 @@ class PronterWindow(MainWindow, pronsole.pronsole):
b.SetForegroundColour("#ffffff") b.SetForegroundColour("#ffffff")
except: except:
if i == newbuttonbuttonindex: if i == newbuttonbuttonindex:
self.newbuttonbutton = b = wx.Button(self.panel, -1, "+", size = (19, 18), style = wx.BU_EXACTFIT) self.newbuttonbutton = b = wx.Button(self.cbuttons_panel, -1, "+", size = (19, 18), style = wx.BU_EXACTFIT)
#b.SetFont(wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)) #b.SetFont(wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
b.SetForegroundColour("#4444ff") b.SetForegroundColour("#4444ff")
b.SetToolTip(wx.ToolTip(_("click to add new custom button"))) b.SetToolTip(wx.ToolTip(_("click to add new custom button")))
b.Bind(wx.EVT_BUTTON, self.cbutton_edit) b.Bind(wx.EVT_BUTTON, self.cbutton_edit)
else: else:
b = wx.Button(self.panel,-1, ".", size = (1, 1)) b = wx.Button(self.cbuttons_panel,-1, ".", size = (1, 1))
#b = wx.StaticText(self.panel,-1, "", size = (72, 22), style = wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE) #+wx.SIMPLE_BORDER #b = wx.StaticText(self.panel,-1, "", size = (72, 22), style = wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE) #+wx.SIMPLE_BORDER
b.Disable() b.Disable()
#continue #continue
......
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