From: nickthetait Date: Mon, 20 Jul 2015 16:44:12 +0000 (-0600) Subject: Add UI elements for V2 Toolheads and basic settings X-Git-Tag: lulzbot-15.02.1-2.01~56^2~40 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=d9a30720a9b53050610299d91a5da127e3a6d8ac;p=cura.git Add UI elements for V2 Toolheads and basic settings --- diff --git a/Cura/gui/configBase.py b/Cura/gui/configBase.py index f45fe157..81c0aa51 100644 --- a/Cura/gui/configBase.py +++ b/Cura/gui/configBase.py @@ -1,4 +1,5 @@ from __future__ import division +from Cura.gui.configWizard import ConfigWizard __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License" import wx, wx.lib.stattext, types @@ -247,3 +248,99 @@ class SettingRow(object): self.ctrl.SetValue(_(value)) else: self.ctrl.SetValue(value) + +class ToolheadRow(object): + def __init__(self, panel, configName, valueOverride = None, index = None): + sizer = panel.GetSizer() + x = sizer.GetRows() + y = 0 + flag = 0 + + self.setting = profile.settingsDictionary[configName] + self.settingIndex = index + self.validationMsg = '' + self.panel = panel + + self.label = wx.lib.stattext.GenStaticText(panel, -1, self.setting.getLabel()) + self.label.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) + + self.ctrl = wx.TextCtrl(panel, -1, self.setting.getValue(self.settingIndex)) + self.ctrl.Enable(False) + + self.changeToolheadButton = wx.Button(panel, -1, "Change Toolhead") + self.changeToolheadButton.Bind(wx.EVT_BUTTON, self.OnChangeToolheadButton) + self.flashButton = wx.Button(panel, -1, "Re-flash Firmware") + self.flashButton.Bind(wx.EVT_BUTTON, self.OnFlashButton) + + flag = wx.EXPAND + self.ctrl.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) + sizer.Add(self.label, (x,y), flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT,border=10) + sizer.Add(self.ctrl, (x,y+1), flag=wx.ALIGN_CENTER_VERTICAL|flag) + sizer.Add(self.changeToolheadButton, (x,y+2), flag=wx.ALIGN_CENTER_VERTICAL|flag) + sizer.Add(self.flashButton, (x,y+3), flag=wx.ALIGN_CENTER_VERTICAL|flag) + sizer.SetRows(x+1) + + self.ctrl.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) + if isinstance(self.ctrl, floatspin.FloatSpin): + self.ctrl.GetTextCtrl().Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) + self.defaultBGColour = self.ctrl.GetTextCtrl().GetBackgroundColour() + else: + self.defaultBGColour = self.ctrl.GetBackgroundColour() + + panel.main.settingControlList.append(self) + + def OnFlashButton(self, e): + framey = PopUp(parent=None, id=-1, text="flash firmware") + framey.Show() + + def OnChangeToolheadButton(self, e): + import configWizard + import wx.wizard + self.ToolheadSelectPage = configWizard.ToolheadSelectPage(self) + wx.wizard.WizardPageSimple.Chain(self, self.GetParent().ToolheadSelectPage) + self.ToolheadSelectPage.test() + + #framey = PopUp(parent=None, id=-1, text="toolhead changer") + #framey.Show() + + def OnMouseEnter(self, e): + self.label.SetToolTipString(self.setting.getTooltip()) + self.ctrl.SetToolTipString(self.setting.getTooltip()) + + def OnMouseExit(self, e): + self.label.SetToolTipString('') + self.ctrl.SetToolTipString('') + e.Skip() + + def GetValue(self): + if isinstance(self.ctrl, wx.ColourPickerCtrl): + return str(self.ctrl.GetColour().GetAsString(wx.C2S_HTML_SYNTAX)) + elif isinstance(self.ctrl, wx.ComboBox): + value = unicode(self.ctrl.GetValue()) + for ret in self._englishChoices: + if _(ret) == value: + return ret + return value + else: + return str(self.ctrl.GetValue()) + + def SetValue(self, value): + if isinstance(self.ctrl, wx.CheckBox): + self.ctrl.SetValue(str(value) == "True") + elif isinstance(self.ctrl, wx.ColourPickerCtrl): + self.ctrl.SetColour(value) + elif isinstance(self.ctrl, floatspin.FloatSpin): + try: + self.ctrl.SetValue(float(value)) + except ValueError: + pass + elif isinstance(self.ctrl, wx.ComboBox): + self.ctrl.SetValue(_(value)) + else: + self.ctrl.SetValue(value) + +class PopUp(wx.Frame): + def __init__(self, parent, id, text): + wx.Frame.__init__(self, parent, id, 'Frame title', size=(400,300)) + panely = wx.Panel(self) + wx.StaticText(panely, -1, text, (10,10)) diff --git a/Cura/gui/configWizard.py b/Cura/gui/configWizard.py index 839322c8..182f2dba 100644 --- a/Cura/gui/configWizard.py +++ b/Cura/gui/configWizard.py @@ -1011,6 +1011,17 @@ class LulzbotReadyPage(InfoPage): self.AddText(_('For more information about using Cura with your LulzBot')) self.AddText(_('3D printer, please visit www.LulzBot.com/cura')) self.AddSeperator() + +class ToolheadSelectPage(InfoPage): + def __init__(self, parent): + super(ToolheadSelectPage, self).__init__(parent, _("LulzBot Toolhead Selection")) + printer_name = profile.getMachineSetting('machine_type') + + self.AddText(_('Selected printer is ({}).'.format(printer_name))) + self.Show() + + def test(self): + print("This is a test!") class Taz5NozzleSelectPage(InfoPage): url='http://lulzbot.com/printer-identification' diff --git a/Cura/gui/preferencesDialog.py b/Cura/gui/preferencesDialog.py index bdeedf5b..eab853bc 100644 --- a/Cura/gui/preferencesDialog.py +++ b/Cura/gui/preferencesDialog.py @@ -122,6 +122,12 @@ class machineSettingsDialog(wx.Dialog): configBase.SettingRow(left, 'machine_shape', index=idx) configBase.SettingRow(left, 'gcode_flavor', index=idx) + printer_type = profile.getMachineSetting('machine_type', idx) + isLulzBot = (printer_type.startswith('lulzbot_')) + if(isLulzBot): + configBase.TitleRow(right, _("Toolhead")) + configBase.ToolheadRow(right, 'toolhead', index=idx) + configBase.TitleRow(right, _("Printer head size")) configBase.SettingRow(right, 'extruder_head_size_min_x', index=idx) configBase.SettingRow(right, 'extruder_head_size_min_y', index=idx) diff --git a/Cura/util/profile.py b/Cura/util/profile.py index 69360706..2ac0e182 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -552,6 +552,7 @@ setting('serial_port_auto', '', str, 'machine', 'hidden') setting('serial_baud', 'AUTO', str, 'machine', 'hidden').setLabel(_("Baudrate"), _("Speed of the serial port communication\nNeeds to match your firmware settings\nCommon values are 250000, 115200, 57600")) setting('serial_baud_auto', '', int, 'machine', 'hidden') +setting('toolhead', 'Default', str, 'machine', 'hidden').setLabel(_("Installed toolhead"), _("Which toolhead is currently installed. This setting is only used by LulzBot machines.")) setting('extruder_head_size_min_x', '0.0', float, 'machine', 'hidden').setLabel(_("Head size towards X min (mm)"), _("The head size when printing multiple objects, measured from the tip of the nozzle towards the outer part of the head.")) setting('extruder_head_size_min_y', '0.0', float, 'machine', 'hidden').setLabel(_("Head size towards Y min (mm)"), _("The head size when printing multiple objects, measured from the tip of the nozzle towards the outer part of the head.")) setting('extruder_head_size_max_x', '0.0', float, 'machine', 'hidden').setLabel(_("Head size towards X max (mm)"), _("The head size when printing multiple objects, measured from the tip of the nozzle towards the outer part of the head."))