X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=Cura%2Fgui%2FconfigWizard.py;h=b5d8fa92f5f3d1300186eb7df39162fd53b49e09;hb=730e8f2c1c8dfc9498a1b416cc398606f60940c3;hp=f2dff42cd66f1c8b07e5c893d011b56dc91f786d;hpb=02a0c396794e2d0e04ffb71e353ea62314ac2967;p=cura.git diff --git a/Cura/gui/configWizard.py b/Cura/gui/configWizard.py index f2dff42c..b5d8fa92 100644 --- a/Cura/gui/configWizard.py +++ b/Cura/gui/configWizard.py @@ -15,6 +15,7 @@ from Cura.util import machineCom from Cura.util import profile from Cura.util import gcodeGenerator from Cura.util import resources +from Cura.util import version class InfoBox(wx.Panel): @@ -62,7 +63,8 @@ class InfoBox(wx.Panel): self.extraInfoUrl = extraInfoUrl self.SetBackgroundColour('#FF8080') self.text.SetLabel(info) - self.extraInfoButton.Show(True) + if extraInfoUrl: + self.extraInfoButton.Show(True) self.Layout() self.SetErrorIndicator() self.Refresh() @@ -124,20 +126,24 @@ class ImageButton(wx.Panel): self.group = ImageButton.__last_group__ else: self.group = None - self.sizer = wx.BoxSizer(wx.VERTICAL) + self.sizer = wx.StaticBoxSizer(wx.StaticBox(self), wx.VERTICAL) self.SetSizer(self.sizer) self.bitmap = bitmap + self.original_overlay = overlay self.overlay = self.createOverlay(bitmap, overlay) self.text = wx.StaticText(self, -1, label) self.bmp = wx.StaticBitmap(self, -1, self.bitmap) if extra_label: self.extra_text = wx.StaticText(self, -1, extra_label) + else: + self.extra_text = None self.selected = False + self.callback = None - self.sizer.Add(self.text, 0, flag=wx.ALL|wx.ALIGN_CENTER, border=5) + self.sizer.Add(self.text, 0, flag=wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER, border=5) self.sizer.Add(self.bmp, 1, flag=wx.ALL|wx.ALIGN_CENTER|wx.EXPAND, border=5) - if extra_label: - self.sizer.Add(self.extra_text, 0, flag=wx.ALL|wx.ALIGN_CENTER, border=5) + if self.extra_text: + self.sizer.Add(self.extra_text, 0, flag=wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER, border=5) self.bmp.Bind(wx.EVT_LEFT_UP, self.OnLeftClick) def __del__(self): @@ -150,6 +156,16 @@ class ImageButton(wx.Panel): if ImageButton.__last_group__ == self: ImageButton.__last_group__ = None + def TriggerGroupCallbacks(self): + if self.group: + for ib in ImageButton.__groups__[self.group]: + if ib.GetValue() and ib.callback: + ib.callback() + break + else: + if self.GetValue() and self.callback: + self.callback() + def OnLeftClick(self, e): self.SetValue(True) @@ -157,6 +173,7 @@ class ImageButton(wx.Panel): return self.selected def SetValue(self, value): + old_value = self.selected self.selected = bool(value) self.bmp.SetBitmap(self.overlay if self.GetValue() else self.bitmap) if self.selected and self.group: @@ -165,6 +182,35 @@ class ImageButton(wx.Panel): continue ib.SetValue(False) self.Layout() + if self.callback and not old_value and self.selected: + self.callback() + + def SetLabel(self, label): + self.text.SetLabel(label) + self.Layout() + + def SetExtraLabel(self, label): + if self.extra_text: + self.extra_text.SetLabel(label) + else: + self.extra_text = wx.StaticText(self, -1, label) + self.sizer.Add(self.extra_text, 0, flag=wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER, border=5) + self.Layout() + + def SetBitmap(self, bitmap): + self.bitmap = bitmap + self.overlay = self.createOverlay(bitmap, self.original_overlay) + self.bmp.SetBitmap(self.overlay if self.GetValue() else self.bitmap) + self.Layout() + + def SetOverlay(self, overlay): + self.original_overlay = overlay + self.overlay = self.createOverlay(self.bitmap, self.original_overlay) + self.bmp.SetBitmap(self.overlay if self.GetValue() else self.bitmap) + self.Layout() + + def OnSelected(self, callback): + self.callback = callback def createOverlay(self, bitmap, overlay): result = bitmap.GetSubBitmap(wx.Rect(0, 0, *bitmap.Size)) @@ -196,16 +242,19 @@ class InfoPage(wx.wizard.WizardPageSimple): # get out of bounds of the widgets area and hide other widgets. # The only way I found for the widget to get its right size was to calculate # the new font's extent and set the min size on the widget - dc = wx.ScreenDC() - dc.SetFont(font) - w,h = dc.GetTextExtent(title) - self.title.SetMinSize((w, h)) + self.title.SetMinSize(self.GetTextExtent(font, title)) sizer.Add(self.title, pos=(0, 0), span=(1, 2), flag=wx.ALIGN_CENTRE | wx.ALL) sizer.Add(wx.StaticLine(self, -1), pos=(1, 0), span=(1, 2), flag=wx.EXPAND | wx.ALL) sizer.AddGrowableCol(1) self.rowNr = 2 + def GetTextExtent(self, font, text): + dc = wx.ScreenDC() + dc.SetFont(font) + w,h = dc.GetTextExtent(text) + return (w, h) + def AddText(self, info): text = wx.StaticText(self, -1, info) self.GetSizer().Add(text, pos=(self.rowNr, 0), span=(1, 2), flag=wx.LEFT | wx.RIGHT) @@ -306,6 +355,20 @@ class InfoPage(wx.wizard.WizardPageSimple): self.rowNr += 1 return combo + def AddImageButton(self, panel, x, y, label, filename, image_size=None, + extra_label=None, overlay=ImageButton.DefaultOverlay, style=None): + ib = ImageButton(panel, label, self.GetBitmap(filename, image_size), extra_label, overlay, style) + panel.GetSizer().Add(ib, pos=(x, y), flag=wx.LEFT | wx.RIGHT | wx.BOTTOM, border=10) + return ib + + def GetBitmap(self, filename, image_size): + if image_size == None: + return wx.Bitmap(resources.getPathForImage(filename)) + else: + image = wx.Image(resources.getPathForImage(filename)) + image_scaled = image.Scale(image_size[0], image_size[1], wx.IMAGE_QUALITY_HIGH) + return wx.BitmapFromImage(image_scaled) + def AllowNext(self): return True @@ -473,13 +536,6 @@ class MachineSelectPage(InfoPage): super(MachineSelectPage, self).__init__(parent, _("Select your machine")) self.AddText(_("What kind of machine do you have:")) - self.LulzbotMiniRadio = self.AddRadioButton("LulzBot Mini", style=wx.RB_GROUP) - self.LulzbotMiniRadio.Bind(wx.EVT_RADIOBUTTON, self.OnLulzbotSelect) - self.LulzbotMiniRadio.SetValue(True) - self.LulzbotTaz5Radio = self.AddRadioButton("LulzBot TAZ 5") - self.LulzbotTaz5Radio.Bind(wx.EVT_RADIOBUTTON, self.OnTaz5Select) - self.LulzbotTaz4Radio = self.AddRadioButton("LulzBot TAZ 4") - self.LulzbotTaz4Radio.Bind(wx.EVT_RADIOBUTTON, self.OnLulzbotSelect) self.Ultimaker2Radio = self.AddRadioButton("Ultimaker2") self.Ultimaker2Radio.Bind(wx.EVT_RADIOBUTTON, self.OnUltimaker2Select) self.Ultimaker2ExtRadio = self.AddRadioButton("Ultimaker2extended") @@ -507,22 +563,9 @@ class MachineSelectPage(InfoPage): def OnPrintrbotSelect(self, e): wx.wizard.WizardPageSimple.Chain(self, self.GetParent().printrbotSelectType) - def OnLulzbotSelect(self, e): - wx.wizard.WizardPageSimple.Chain(self, self.GetParent().lulzbotToolheadPage) - - def OnTaz5Select(self, e): - wx.wizard.WizardPageSimple.Chain(self, self.GetParent().taz5NozzleSelectPage) - wx.wizard.WizardPageSimple.Chain(self.GetParent().taz5NozzleSelectPage, self.GetParent().lulzbotToolheadPage) - def OnOtherSelect(self, e): wx.wizard.WizardPageSimple.Chain(self, self.GetParent().otherMachineSelectPage) - def AllowNext(self): - return True - - def AllowBack(self): - return False - def StoreData(self): profile.putProfileSetting('retraction_enable', 'True') if self.Ultimaker2Radio.GetValue() or self.Ultimaker2GoRadio.GetValue() or self.Ultimaker2ExtRadio.GetValue(): @@ -589,44 +632,6 @@ class MachineSelectPage(InfoPage): profile.putMachineSetting('has_heated_bed', 'True') profile.putMachineSetting('extruder_amount', '1') profile.putProfileSetting('retraction_enable', 'True') - elif self.LulzbotTaz4Radio.GetValue() or self.LulzbotTaz5Radio.GetValue() or self.LulzbotMiniRadio.GetValue(): - if self.LulzbotTaz4Radio.GetValue(): - profile.putMachineSetting('machine_width', '290') - profile.putMachineSetting('machine_depth', '275') - profile.putMachineSetting('machine_height', '250') - profile.putProfileSetting('nozzle_size', '0.35') - profile.putMachineSetting('machine_name', 'LulzBot TAZ 4') - profile.putMachineSetting('machine_type', 'lulzbot_TAZ_4') - profile.putMachineSetting('serial_baud', '115200') - elif self.LulzbotTaz5Radio.GetValue(): - profile.putMachineSetting('machine_width', '290') - profile.putMachineSetting('machine_depth', '275') - profile.putMachineSetting('machine_height', '250') - profile.putMachineSetting('serial_baud', '115200') - # Machine type and name are set in the nozzle select page - else: - profile.putMachineSetting('machine_width', '155') - profile.putMachineSetting('machine_depth', '155') - profile.putMachineSetting('machine_height', '163') - profile.putProfileSetting('nozzle_size', '0.5') - profile.putMachineSetting('machine_name', 'LulzBot Mini') - profile.putMachineSetting('machine_type', 'lulzbot_mini') - profile.putMachineSetting('serial_baud', '115200') - profile.putMachineSetting('extruder_head_size_min_x', '40') - profile.putMachineSetting('extruder_head_size_max_x', '75') - profile.putMachineSetting('extruder_head_size_min_y', '25') - profile.putMachineSetting('extruder_head_size_max_y', '55') - profile.putMachineSetting('extruder_head_size_height', '17') - - profile.putMachineSetting('machine_center_is_zero', 'False') - profile.putMachineSetting('gcode_flavor', 'RepRap (Marlin/Sprinter)') - profile.putMachineSetting('has_heated_bed', 'True') - profile.putMachineSetting('extruder_head_size_min_x', '0.0') - profile.putMachineSetting('extruder_head_size_min_y', '0.0') - profile.putMachineSetting('extruder_head_size_max_x', '0.0') - profile.putMachineSetting('extruder_head_size_max_y', '0.0') - profile.putMachineSetting('extruder_head_size_height', '0.0') - profile.putPreference('startMode', 'Simple') else: profile.putMachineSetting('machine_width', '80') profile.putMachineSetting('machine_depth', '80') @@ -673,7 +678,7 @@ class SelectParts(InfoPage): class UltimakerFirmwareUpgradePage(InfoPage): def __init__(self, parent): super(UltimakerFirmwareUpgradePage, self).__init__(parent, _("Upgrade Ultimaker Firmware")) - self.AddText(_("Firmware is the piece of software running directly on your 3D printer.\nThis firmware controls the step motors, regulates the temperature\nand ultimately makes your printer work.")) + self.AddText(_("Firmware is the piece of software running directly on your 3D printer.\nThis firmware controls the stepper motors, regulates the temperature\nand ultimately makes your printer work.")) self.AddHiddenSeperator() self.AddText(_("The firmware shipping with new Ultimakers works, but upgrades\nhave been made to make better prints, and make calibration easier.")) self.AddHiddenSeperator() @@ -1094,151 +1099,466 @@ class Ultimaker2ReadyPage(InfoPage): self.AddText(_('Cura is now ready to be used with your Ultimaker2.')) self.AddSeperator() +class LulzbotMachineSelectPage(InfoPage): + IMAGE_WIDTH=300 + IMAGE_HEIGHT=200 + + def __init__(self, parent): + super(LulzbotMachineSelectPage, self).__init__(parent, _("Select your machine")) + + self.panel = self.AddPanel() + + image_size=(LulzbotMachineSelectPage.IMAGE_WIDTH, LulzbotMachineSelectPage.IMAGE_HEIGHT) + self.LulzbotMini = self.AddImageButton(self.panel, 0, 0, _("LulzBot Mini"), + 'Lulzbot_mini.jpg', image_size, style=ImageButton.IB_GROUP) + self.LulzbotMini.OnSelected(self.OnLulzbotMiniSelected) + + self.LulzbotTaz6 = self.AddImageButton(self.panel, 0, 1, _("LulzBot TAZ 6"), + 'Lulzbot_TAZ6.jpg', image_size) + self.LulzbotTaz6.OnSelected(self.OnLulzbotTaz6Selected) + + self.LulzbotTaz = self.AddImageButton(self.panel, 1, 0, _("LulzBot TAZ 4 or 5"), + 'Lulzbot_TAZ5.jpg', image_size) + self.LulzbotTaz.OnSelected(self.OnLulzbotTazSelected) + + self.OtherPrinters = self.AddImageButton(self.panel, 1, 1, _("Other Printers"), + 'Generic-3D-Printer.png', image_size) + self.OtherPrinters.OnSelected(self.OnOthersSelected) + self.LulzbotMini.SetValue(True) + + def OnPageShown(self): + self.LulzbotMini.TriggerGroupCallbacks() + + def OnOthersSelected(self): + wx.wizard.WizardPageSimple.Chain(self, self.GetParent().machineSelectPage) + + def OnLulzbotMiniSelected(self): + wx.wizard.WizardPageSimple.Chain(self, self.GetParent().lulzbotMiniToolheadPage) + wx.wizard.WizardPageSimple.Chain(self.GetParent().lulzbotMiniToolheadPage, + self.GetParent().lulzbotReadyPage) + + def OnLulzbotTaz6Selected(self): + wx.wizard.WizardPageSimple.Chain(self, self.GetParent().lulzbotTaz6SelectPage) + + def OnLulzbotTazSelected(self): + wx.wizard.WizardPageSimple.Chain(self, self.GetParent().lulzbotTazSelectPage) + + def AllowNext(self): + return True + + def AllowBack(self): + return False + + def StoreData(self): + if self.LulzbotTaz.GetValue() or self.LulzbotMini.GetValue(): + if self.LulzbotTaz.GetValue(): + profile.putMachineSetting('machine_width', '290') + profile.putMachineSetting('machine_depth', '275') + profile.putMachineSetting('machine_height', '250') + profile.putMachineSetting('serial_baud', '115200') + profile.putMachineSetting('extruder_head_size_min_x', '0.0') + profile.putMachineSetting('extruder_head_size_max_x', '0.0') + profile.putMachineSetting('extruder_head_size_min_y', '0.0') + profile.putMachineSetting('extruder_head_size_max_y', '0.0') + profile.putMachineSetting('extruder_head_size_height', '0.0') + else: + # Nozzle diameter and machine type will be set in the toolhead selection page + profile.putMachineSetting('machine_name', 'LulzBot Mini') + profile.putMachineSetting('machine_width', '155') + profile.putMachineSetting('machine_depth', '155') + profile.putMachineSetting('machine_height', '163') + profile.putMachineSetting('serial_baud', '115200') + profile.putMachineSetting('extruder_head_size_min_x', '40') + profile.putMachineSetting('extruder_head_size_max_x', '75') + profile.putMachineSetting('extruder_head_size_min_y', '25') + profile.putMachineSetting('extruder_head_size_max_y', '55') + profile.putMachineSetting('extruder_head_size_height', '17') + + profile.putMachineSetting('machine_center_is_zero', 'False') + profile.putMachineSetting('gcode_flavor', 'RepRap (Marlin/Sprinter)') + profile.putMachineSetting('has_heated_bed', 'True') + profile.putProfileSetting('retraction_enable', 'True') + profile.putPreference('startMode', 'Simple') + profile.putProfileSetting('wall_thickness', float(profile.getProfileSetting('nozzle_size')) * 2) + profile.checkAndUpdateMachineName() + class LulzbotReadyPage(InfoPage): def __init__(self, parent): super(LulzbotReadyPage, self).__init__(parent, _("LulzBot TAZ/Mini")) - self.AddBitmap(wx.Bitmap(resources.getPathForImage('Lulzbot_logo.png'))) self.AddText(_('Cura is now ready to be used with your LulzBot 3D printer.')) self.AddSeperator() self.AddText(_('For more information about using Cura with your LulzBot')) self.AddText(_('3D printer, please visit www.LulzBot.com/cura')) self.AddSeperator() -class LulzbotToolheadSelectPage(InfoPage): - url='http://lulzbot.com/toolhead-identification' +class LulzbotMiniToolheadSelectPage(InfoPage): + def __init__(self, parent, allowBack = True): + super(LulzbotMiniToolheadSelectPage, self).__init__(parent, _("LulzBot Mini Tool Head Selection")) + + self.allowBack = allowBack + self.panel = self.AddPanel() + image_size=(LulzbotMachineSelectPage.IMAGE_WIDTH, LulzbotMachineSelectPage.IMAGE_HEIGHT) + self.standard = self.AddImageButton(self.panel, 0, 0, _('Standard LulzBot Mini'), + 'Lulzbot_mini.jpg', image_size, + style=ImageButton.IB_GROUP) + self.flexy = self.AddImageButton(self.panel, 0, 1, _('LulzBot Mini with Flexystruder'), + 'Lulzbot_Toolhead_Mini_Flexystruder.jpg', image_size) + self.standard.SetValue(True) + def AllowBack(self): + return self.allowBack + + def StoreData(self): + if self.standard.GetValue(): + profile.putProfileSetting('nozzle_size', '0.5') + profile.putMachineSetting('extruder_amount', '1') + profile.putMachineSetting('toolhead', 'Single Extruder v2') + profile.putMachineSetting('toolhead_shortname', '') + profile.putMachineSetting('machine_type', 'lulzbot_mini') + else: + profile.putProfileSetting('nozzle_size', '0.6') + profile.putMachineSetting('extruder_amount', '1') + profile.putMachineSetting('toolhead', 'Flexystruder v2') + profile.putMachineSetting('toolhead_shortname', 'Flexystruder') + profile.putMachineSetting('machine_type', 'lulzbot_mini_flexystruder') + +class LulzbotTaz6SelectPage(InfoPage): def __init__(self, parent): - super(LulzbotToolheadSelectPage, self).__init__(parent, _("LulzBot Toolhead Selection")) - - self.mini_choices = [_('Standard'), _('Flexystruder')] - self.taz_choices = [_('Standard v1'), - _('Standard v2 0.35 mm nozzle'), _('Standard v2 0.5 mm nozzle'), - _('Flexystruder v1'), _('Flexystruder v2'), - _('Dually v1'), _('Dually v2'), - _('FlexyDually v1'), _('FlexyDually v2')] - self.description_map = { - _('Standard'): _('This is the standard toolhead that comes with the Lulzbot Mini'), - _('Flexystruder'): _('This is the Flexystruder for the Lulzbot Mini\nIt is used for printing Flexible materials'), - _('Standard v1'): _('This is the standard toolhead that comes with the Lulzbot TAZ 1-2-3 and TAZ 4.\nIt uses the Budaschnozzle for the hotend'), - _('Standard v2 0.35 mm nozzle'): _('This is the standard toolhead that comes with the Lulzbot TAZ 5.\nIt uses the Hexagon hotend and a 0.35 mm nozzle'), - _('Standard v2 0.5 mm nozzle'): _('This is the standard toolhead that comes with the Lulzbot TAZ 5.\nIt uses the Hexagon hotend and a 0.5 mm nozzle'), - _('Flexystruder v1'): _('It\'s the flexy!'), - _('Flexystruder v2'): _('It\'s the flexy v2!'), - _('Dually v1'): _('It\'s the dualy v1!'), - _('Dually v2'): _('It\'s the dual v2!'), - _('FlexyDually v1'): _('It\'s the flexy dually v1!'), - _('FlexyDually v2'): _('It\'s the flexy dual v2!') - } - self.image_map = { - _('Standard'): 'Lulzbot_Toolhead_Mini_Standard.jpg', - _('Flexystruder'): 'Lulzbot_logo.png', - _('Standard v1'): 'Lulzbot_logo.png', - _('Standard v2 0.35 mm nozzle'): 'Lulzbot_Toolhead_TAZ_Single_v2.jpg', - _('Standard v2 0.5 mm nozzle'): 'Lulzbot_Toolhead_TAZ_Single_v2.jpg', - _('Flexystruder v1'): 'Lulzbot_Toolhead_TAZ_Flexystruder_v1.jpg', - _('Flexystruder v2'): 'Lulzbot_logo.png', - _('Dually v1'): 'Lulzbot_Toolhead_TAZ_Dually_v1.jpg', - _('Dually v2'): 'Lulzbot_logo.png', - _('FlexyDually v1'): 'Lulzbot_logo.png', - _('FlexyDually v2'): 'Lulzbot_logo.png' - } - self.AddBitmap(wx.Bitmap(resources.getPathForImage('LulzBot_logo.png'))) - printer_name = profile.getMachineSetting('machine_type') - self.Bind(wx.wizard.EVT_WIZARD_PAGE_SHOWN, self.OnPageShown) - - self.AddText(_('Please select your currently installed Tool Head')) - txt = self.AddText(_('It is important to select the correct Tool head for your printer.\n' + - 'Flashing the wrong firmware on your printer can cause damage to your printer and to your toolhead\n' + - 'If you are not sure which toolhead you have, please refer to this webpage for more information: ')) - txt.SetForegroundColour(wx.RED) - button = self.AddButton(self.url) - button.Bind(wx.EVT_BUTTON, self.OnUrlClick) + super(LulzbotTaz6SelectPage, self).__init__(parent, _("LulzBot TAZ 6 Selection")) + + self.panel = self.AddPanel() + image_size=(LulzbotMachineSelectPage.IMAGE_WIDTH, LulzbotMachineSelectPage.IMAGE_HEIGHT) + self.taz6 = self.AddImageButton(self.panel, 0, 0, _('Tilapia'), + 'Lulzbot_Toolhead_TAZ_Tilapia.jpg', image_size, + style=ImageButton.IB_GROUP) + self.taz6.OnSelected(self.OnTilapiaSelected) + self.taz6.SetValue(True) + + def OnPageShown(self): + self.taz6.TriggerGroupCallbacks() + + def OnTilapiaSelected(self): + wx.wizard.WizardPageSimple.Chain(self, self.GetParent().lulzbotReadyPage) + + def StoreData(self): + profile.putProfileSetting('nozzle_size', '0.5') + profile.putMachineSetting('extruder_amount', '1') + profile.putMachineSetting('toolhead', 'Single Extruder Tilapia') + profile.putMachineSetting('toolhead_shortname', 'Tilapia') + profile.putMachineSetting('machine_type', 'lulzbot_TAZ_6_Single_Tilapia') + profile.putMachineSetting('machine_name', 'LulzBot TAZ 6') + +class LulzbotTazSelectPage(InfoPage): + def __init__(self, parent): + super(LulzbotTazSelectPage, self).__init__(parent, _("LulzBot TAZ 4-5 Selection")) + + self.panel = self.AddPanel() + image_size=(LulzbotMachineSelectPage.IMAGE_WIDTH, LulzbotMachineSelectPage.IMAGE_HEIGHT) + self.taz5 = self.AddImageButton(self.panel, 0, 0, _('Stock TAZ 5 (PEI && v2)'), + 'Lulzbot_TAZ_5_Hex_and_PEI.jpg', image_size, + style=ImageButton.IB_GROUP) + self.taz5.OnSelected(self.OnTaz5Selected) + self.taz4 = self.AddImageButton(self.panel, 0, 1, _('Stock TAZ 4 (PET && v1)'), + 'Lulzbot_TAZ_4_Buda_and_PET.jpg', image_size) + self.taz4.OnSelected(self.OnTaz4Selected) + self.modified = self.AddImageButton(self.panel, 1, 0, _('Modified LulzBot TAZ 4 or 5'), + 'Lulzbot_TAZ5.jpg', image_size) + self.modified.OnSelected(self.OnModifiedSelected) + self.taz5.SetValue(True) + + def OnPageShown(self): + self.taz5.TriggerGroupCallbacks() + + def OnTaz5Selected(self): + wx.wizard.WizardPageSimple.Chain(self, self.GetParent().lulzbotTaz5NozzleSelectPage) + wx.wizard.WizardPageSimple.Chain(self.GetParent().lulzbotTaz5NozzleSelectPage, + self.GetParent().lulzbotReadyPage) + + def OnTaz4Selected(self): + wx.wizard.WizardPageSimple.Chain(self, self.GetParent().lulzbotReadyPage) + + def OnModifiedSelected(self): + wx.wizard.WizardPageSimple.Chain(self, self.GetParent().lulzbotTazBedSelectPage) + wx.wizard.WizardPageSimple.Chain(self.GetParent().lulzbotTazBedSelectPage, + self.GetParent().lulzbotTazHotendPage) + + def StoreData(self): + if self.taz5.GetValue(): + profile.putProfileSetting('nozzle_size', '0.5') + profile.putMachineSetting('extruder_amount', '1') + profile.putMachineSetting('toolhead', 'Single Extruder V2') + profile.putMachineSetting('toolhead_shortname', '') + profile.putMachineSetting('machine_type', 'lulzbot_TAZ_5_SingleV2') + profile.putMachineSetting('machine_name', 'LulzBot TAZ 5') + elif self.taz4.GetValue(): + profile.putProfileSetting('nozzle_size', '0.35') + profile.putMachineSetting('extruder_amount', '1') + profile.putMachineSetting('toolhead', 'Single Extruder V1') + profile.putMachineSetting('toolhead_shortname', '') + profile.putMachineSetting('machine_type', 'lulzbot_TAZ_4_SingleV1') + profile.putMachineSetting('machine_name', 'LulzBot TAZ 4') + +class LulzbotTazBedSelectPage(InfoPage): + def __init__(self, parent): + super(LulzbotTazBedSelectPage, self).__init__(parent, _("Bed Surface")) - self.AddSeperator() - #self.combo = self.AddCombo(_('Currently installed Toolhead'), ['']) - #self.combo.SetEditable(False) - #self.combo.Bind(wx.EVT_COMBOBOX, self.OnToolheadSelected) - #self.description = self.AddText('\n\n') - #self.description.SetFont(wx.Font(11, wx.SWISS, wx.NORMAL, wx.BOLD)) - #self.image = self.AddBitmap(wx.Bitmap(resources.getPathForImage(self.image_map[self.mini_choices[0]]))) self.panel = self.AddPanel() - ib1 = ImageButton(self.panel, "Mini", wx.Bitmap(resources.getPathForImage('Lulzbot_Toolhead_TAZ_Flexystruder_v1.jpg')), "Some description", style=ImageButton.IB_GROUP) - ib2 = ImageButton(self.panel, "TAZ 4 ", wx.Bitmap(resources.getPathForImage('Lulzbot_Toolhead_TAZ_Single_v2.jpg')), "Some description 2") - ib3 = ImageButton(self.panel, "TAZ 5 ", wx.Bitmap(resources.getPathForImage('Lulzbot_Toolhead_TAZ_Flexystruder_v1.jpg'))) - ib4 = ImageButton(self.panel, "Others ", wx.Bitmap(resources.getPathForImage('Lulzbot_Toolhead_TAZ_Dually_v1.jpg'))) - self.panel.GetSizer().Add(ib1, pos=(0, 0), flag=wx.EXPAND) - self.panel.GetSizer().Add(ib2, pos=(0, 1), flag=wx.EXPAND) - self.panel.GetSizer().Add(ib3, pos=(1, 0), flag=wx.EXPAND) - self.panel.GetSizer().Add(ib4, pos=(1, 1), flag=wx.EXPAND) - - - def OnPageShown(self, e): - printer_name = profile.getMachineSetting('machine_type') - if printer_name == 'lulzbot_mini': - choices = self.mini_choices - default = 0 + image_size=(LulzbotMachineSelectPage.IMAGE_WIDTH, LulzbotMachineSelectPage.IMAGE_HEIGHT) + self.pei = self.AddImageButton(self.panel, 0, 0, _('PEI'), + 'Lulzbot_TAZ_PEI_Bed.jpg', image_size, + style=ImageButton.IB_GROUP) + self.pet = self.AddImageButton(self.panel, 0, 1, _('PET'), + 'Lulzbot_TAZ_PET_Bed.jpg', image_size) + self.pei.SetValue(True) + + def StoreData(self): + if self.pei.GetValue(): + profile.putMachineSetting('machine_type', 'lulzbot_TAZ_5') + profile.putMachineSetting('machine_name', 'LulzBot TAZ 5') else: - choices = self.taz_choices - if printer_name == 'lulzbot_TAZ_4': - default = 0 - elif printer_name == 'lulzbot_TAZ_5': - default = 1 + profile.putMachineSetting('machine_type', 'lulzbot_TAZ_4') + profile.putMachineSetting('machine_name', 'LulzBot TAZ 4') + + +class LulzbotTazToolheadSelectPage(InfoPage): + def __init__(self, parent): + super(LulzbotTazToolheadSelectPage, self).__init__(parent, _("LulzBot TAZ Tool Head Selection")) + + self.panel = self.AddPanel() + image_size=(LulzbotMachineSelectPage.IMAGE_WIDTH, LulzbotMachineSelectPage.IMAGE_HEIGHT) + self.single = self.AddImageButton(self.panel, 0, 0, _('Single Extruder v1'), + 'Lulzbot_Toolhead_TAZ_Single_v1.jpg', image_size, + style=ImageButton.IB_GROUP) + self.flexy = self.AddImageButton(self.panel, 0, 1, _('Flexystruder v1'), + 'Lulzbot_Toolhead_TAZ_Flexystruder_v1.jpg', image_size) + self.dually = self.AddImageButton(self.panel, 1, 0, _('Dual Extruder v1'), + 'Lulzbot_Toolhead_TAZ_Dual_Extruder_v1.jpg', image_size) + self.flexydually = self.AddImageButton(self.panel, 1, 1, _('FlexyDually v1'), + 'Lulzbot_Toolhead_TAZ_FlexyDually_v1.jpg', image_size) + self.SetVersion(1) + self.single.SetValue(True) + + def SetVersion(self, version): + image_size=(LulzbotMachineSelectPage.IMAGE_WIDTH, LulzbotMachineSelectPage.IMAGE_HEIGHT) + self.single.SetBitmap(self.GetBitmap('Lulzbot_Toolhead_TAZ_Single_v%d.jpg' % version, image_size)) + self.single.SetLabel(_('Single Extruder v%d' % version)) + self.flexy.SetBitmap(self.GetBitmap('Lulzbot_Toolhead_TAZ_Flexystruder_v%d.jpg' % version, image_size)) + self.flexy.SetLabel(_('Flexystruder v%d' % version)) + self.dually.SetBitmap(self.GetBitmap('Lulzbot_Toolhead_TAZ_Dual_Extruder_v%d.jpg' % version, image_size)) + self.dually.SetLabel(_('Dual Extruder v%d' % version)) + self.flexydually.SetBitmap(self.GetBitmap('Lulzbot_Toolhead_TAZ_FlexyDually_v%d.jpg' % version, image_size)) + self.flexydually.SetLabel(_('FlexyDually v%d' % version)) + self.version = version + if version == 1: + self.single.OnSelected(None) + self.flexy.OnSelected(None) + self.dually.OnSelected(None) + self.flexydually.OnSelected(None) + wx.wizard.WizardPageSimple.Chain(self, self.GetParent().lulzbotFirmwarePage) + elif version == 2: + self.single.OnSelected(self.OnSingleV2) + self.flexy.OnSelected(self.OnNonSingle) + self.dually.OnSelected(self.OnNonSingle) + self.flexydually.OnSelected(self.OnNonSingle) + if self.single.GetValue(): + wx.wizard.WizardPageSimple.Chain(self, self.GetParent().lulzbotTaz5NozzleSelectPage) + wx.wizard.WizardPageSimple.Chain(self.GetParent().lulzbotTaz5NozzleSelectPage, self.GetParent().lulzbotFirmwarePage) else: - default = 2 + wx.wizard.WizardPageSimple.Chain(self, self.GetParent().lulzbotFirmwarePage) + wx.wizard.WizardPageSimple.Chain(self.GetParent().lulzbotFirmwarePage, self.GetParent().lulzbotReadyPage) - self.combo.Clear() - self.combo.AppendItems(choices) - self.combo.SetValue(choices[default]) - self.OnToolheadSelected(e) + def OnSingleV2(self): + wx.wizard.WizardPageSimple.Chain(self, self.GetParent().lulzbotTaz5NozzleSelectPage) + wx.wizard.WizardPageSimple.Chain(self.GetParent().lulzbotTaz5NozzleSelectPage, self.GetParent().lulzbotFirmwarePage) - def OnUrlClick(self, e): - webbrowser.open(LulzbotToolheadSelectPage.url) + def OnNonSingle(self): + wx.wizard.WizardPageSimple.Chain(self, self.GetParent().lulzbotFirmwarePage) - def OnToolheadSelected(self, e): - toolhead = self.combo.GetValue() - if self.description_map.has_key(toolhead): - self.image.SetBitmap(wx.Bitmap(resources.getPathForImage(self.image_map[toolhead]))) - self.description.SetLabel(self.description_map[toolhead]) + def StoreData(self): + if profile.getMachineSetting('machine_type').startswith('lulzbot_TAZ_4'): + taz_version = 4 else: - self.image.SetBitmap(wx.NullBitmap) - self.description.SetLabel('\n\n') - self.Layout() - self.Fit() + taz_version = 5 + version = (taz_version, self.version) + if self.single.GetValue(): + profile.putProfileSetting('nozzle_size', '0.5' if self.version == 2 else '0.35') + profile.putMachineSetting('extruder_amount', '1') + profile.putMachineSetting('toolhead', 'Single Extruder V%d' % self.version) + profile.putMachineSetting('toolhead_shortname', '') + profile.putMachineSetting('machine_type', 'lulzbot_TAZ_%d_SingleV%d' % version) + elif self.flexy.GetValue(): + profile.putProfileSetting('nozzle_size', '0.6') + profile.putMachineSetting('extruder_amount', '1') + profile.putMachineSetting('toolhead', 'Flexystruder V%d' % self.version) + profile.putMachineSetting('toolhead_shortname', 'Flexystruder v%d' % self.version) + profile.putMachineSetting('machine_type', 'lulzbot_TAZ_%d_FlexystruderV%d' % version) + elif self.dually.GetValue(): + profile.putProfileSetting('nozzle_size', '0.5') + profile.putMachineSetting('extruder_amount', '2') + profile.putMachineSetting('extruder_offset_x1', '0.0') + profile.putMachineSetting('extruder_offset_y1', '-50.0' if self.version == 2 else '-52.00') + profile.putMachineSetting('toolhead', 'Dual Extruder V%d' % self.version) + profile.putMachineSetting('toolhead_shortname', 'Dual v%d' % self.version) + profile.putMachineSetting('machine_type', 'lulzbot_TAZ_%d_DualV%d' % version) + elif self.flexydually.GetValue(): + profile.putProfileSetting('nozzle_size', '0.6') + profile.putMachineSetting('extruder_amount', '2') + profile.putMachineSetting('extruder_offset_x1', '0.0') + profile.putMachineSetting('extruder_offset_y1', '-50.0' if self.version == 2 else '-52.00') + profile.putMachineSetting('toolhead', 'FlexyDually V%d' % self.version) + profile.putMachineSetting('toolhead_shortname', 'FlexyDually v%d' % self.version) + profile.putMachineSetting('machine_type', 'lulzbot_TAZ_%d_FlexyDuallyV%d' % version) -class Taz5NozzleSelectPage(InfoPage): - url='http://lulzbot.com/printer-identification' +class LulzbotHotendSelectPage(InfoPage): + def __init__(self, parent, allowBack = True): + super(LulzbotHotendSelectPage, self).__init__(parent, _("LulzBot Tool Head Hot end Selection")) + + self.allowBack = allowBack + self.panel = self.AddPanel() + image_size=(LulzbotMachineSelectPage.IMAGE_WIDTH, LulzbotMachineSelectPage.IMAGE_HEIGHT) + self.v1 = self.AddImageButton(self.panel, 0, 0, _('v1 (Budaschnozzle)'), + 'Lulzbot_Toolhead_v1.jpg', image_size, + style=ImageButton.IB_GROUP) + self.v2 = self.AddImageButton(self.panel, 0, 1, _('v2 (LulzBot Hexagon)'), + 'Lulzbot_Toolhead_v2.jpg', image_size) + self.v1.SetValue(True) + + def AllowBack(self): + return self.allowBack + + def StoreData(self): + self.GetParent().lulzbotTazToolheadPage.SetVersion(1 if self.v1.GetValue() else 2) + +class LulzbotTaz5NozzleSelectPage(InfoPage): + url2='http://lulzbot.com/printer-identification' def __init__(self, parent): - super(Taz5NozzleSelectPage, self).__init__(parent, _("LulzBot TAZ5")) - self.AddBitmap(wx.Bitmap(resources.getPathForImage('Lulzbot_logo.png'))) + super(LulzbotTaz5NozzleSelectPage, self).__init__(parent, _("LulzBot TAZ Single v2 Nozzle Selection")) - self.AddText(_(' ')) - self.AddText(_('Please select nozzle size:')) + self.AddText(_('Please select your LulzBot Hexagon Hot End\'s nozzle diameter:')) self.Nozzle35Radio = self.AddRadioButton("0.35 mm", style=wx.RB_GROUP) self.Nozzle35Radio.SetValue(True) self.Nozzle50Radio = self.AddRadioButton("0.5 mm") self.AddText(_(' ')) self.AddSeperator() - self.AddText(_('If you are not sure which nozzle size you have')) + self.AddText(_('If you are not sure which nozzle diameter you have,')) self.AddText(_('please check this webpage: ')) - button = self.AddButton(Taz5NozzleSelectPage.url) + button = self.AddButton(LulzbotTaz5NozzleSelectPage.url2) button.Bind(wx.EVT_BUTTON, self.OnUrlClick) def OnUrlClick(self, e): - webbrowser.open(Taz5NozzleSelectPage.url) + webbrowser.open(LulzbotTaz5NozzleSelectPage.url2) def StoreData(self): + if profile.getMachineSetting('machine_type').startswith('lulzbot_TAZ_4'): + taz_version = 4 + else: + taz_version = 5 if self.Nozzle35Radio.GetValue(): profile.putProfileSetting('nozzle_size', '0.35') - profile.putMachineSetting('machine_name', 'LulzBot TAZ 5 (0.35 nozzle)') - profile.putMachineSetting('machine_type', 'lulzbot_TAZ_5') + profile.putMachineSetting('toolhead', 'Single Extruder v2 (0.35mm nozzle)') + profile.putMachineSetting('toolhead_shortname', '0.35 nozzle') + profile.putMachineSetting('machine_type', 'lulzbot_TAZ_%d_035nozzle' % taz_version) else: profile.putProfileSetting('nozzle_size', '0.5') - profile.putMachineSetting('machine_name', 'LulzBot TAZ 5 (0.5 nozzle)') - profile.putMachineSetting('machine_type', 'lulzbot_TAZ_5_05nozzle') + profile.putMachineSetting('toolhead', 'Single Extruder v2 (0.5mm nozzle)') + profile.putMachineSetting('toolhead_shortname', '0.5 nozzle') + profile.putMachineSetting('machine_type', 'lulzbot_TAZ_%d_05nozzle' % taz_version) + +class LulzbotFirmwareUpdatePage(InfoPage): + def __init__(self, parent): + super(LulzbotFirmwareUpdatePage, self).__init__(parent, _("LulzBot Firmware Update")) + + self.AddText(_("Your LulzBot printer\'s firmware will now be updated.\n" + + "Note: this will overwrite your existing firmware.")) + self.AddSeperator() + self.AddText(_("Follow these steps to prevent writing firmware to the wrong device:\n" + + " 1) Unplug all USB devices from your computer\n" + + " 2) Plug your 3D Printer into the computer with a USB cable\n" + + " 3) Turn on your 3D Printer\n" + + " 4) Click \"Flash the firmware\"")) + self.AddHiddenSeperator() + upgradeButton, skipUpgradeButton = self.AddDualButton(_('Flash the firmware'), _('Skip upgrade')) + upgradeButton.Bind(wx.EVT_BUTTON, self.OnUpgradeClick) + skipUpgradeButton.Bind(wx.EVT_BUTTON, self.OnSkipClick) + + def AllowNext(self): + return version.isDevVersion() + + def OnUpgradeClick(self, e): + if firmwareInstall.InstallFirmware(): + self.GetParent().FindWindowById(wx.ID_FORWARD).Enable() + self.GetParent().ShowPage(self.GetNext()) + + def OnSkipClick(self, e): + dlg = wx.MessageDialog(self, + _("CAUTION: Updating firmware is necessary when changing the\n" \ + "tool head on your LulzBot desktop 3D Printer." \ + "\n\n" + + "Are you sure you want to skip the firmware update?"), + _('Skip firmware update?'), + wx.YES_NO | wx.ICON_EXCLAMATION) + skip = dlg.ShowModal() == wx.ID_YES + dlg.Destroy() + if skip: + self.GetParent().FindWindowById(wx.ID_FORWARD).Enable() + self.GetParent().ShowPage(self.GetNext()) + +class LulzbotChangeToolheadWizard(wx.wizard.Wizard): + def __init__(self): + super(LulzbotChangeToolheadWizard, self).__init__(None, -1, _("Change LulzBot Tool Head Wizard")) + + self._nozzle_size = profile.getProfileSettingFloat('nozzle_size') + self._machine_name = profile.getMachineSetting('machine_name') + self._machine_type = profile.getMachineSetting('machine_type') + self._extruder_amount = int(profile.getMachineSettingFloat('extruder_amount')) + + self.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGED, self.OnPageChanged) + self.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGING, self.OnPageChanging) + self.Bind(wx.wizard.EVT_WIZARD_CANCEL, self.OnCancel) + + self.lulzbotReadyPage = LulzbotReadyPage(self) + self.lulzbotFirmwarePage = LulzbotFirmwareUpdatePage(self) + self.lulzbotMiniToolheadPage = LulzbotMiniToolheadSelectPage(self, False) + self.lulzbotTazToolheadPage = LulzbotTazToolheadSelectPage(self) + self.lulzbotTazHotendPage = LulzbotHotendSelectPage(self, False) + self.lulzbotTaz5NozzleSelectPage = LulzbotTaz5NozzleSelectPage(self) + self.lulzbotTazBedSelectPage = LulzbotTazBedSelectPage(self) + self.lulzbotTazSelectPage = LulzbotTazSelectPage(self) + self.lulzbotTaz6SelectPage = LulzbotTaz6SelectPage(self) + + wx.wizard.WizardPageSimple.Chain(self.lulzbotMiniToolheadPage, self.lulzbotReadyPage) + wx.wizard.WizardPageSimple.Chain(self.lulzbotTazHotendPage, self.lulzbotTazToolheadPage) + + if profile.getMachineSetting('machine_type').startswith('lulzbot_mini'): + self.RunWizard(self.lulzbotMiniToolheadPage) + else: + self.RunWizard(self.lulzbotTazHotendPage) + self.Destroy() + + def OnPageChanging(self, e): + e.GetPage().StoreData() + + def OnPageChanged(self, e): + if e.GetPage().AllowNext(): + self.FindWindowById(wx.ID_FORWARD).Enable() + else: + self.FindWindowById(wx.ID_FORWARD).Disable() + if e.GetPage().AllowBack(): + self.FindWindowById(wx.ID_BACKWARD).Enable() + else: + self.FindWindowById(wx.ID_BACKWARD).Disable() + if hasattr(e.GetPage(), 'OnPageShown'): + e.GetPage().OnPageShown() + + def OnCancel(self, e): + profile.putProfileSetting('nozzle_size', self._nozzle_size) + profile.putMachineSetting('machine_name', self._machine_name) + profile.putMachineSetting('machine_type', self._machine_type) + profile.putMachineSetting('extruder_amount', self._extruder_amount) class ConfigWizard(wx.wizard.Wizard): def __init__(self, addNew = False): @@ -1267,21 +1587,26 @@ class ConfigWizard(wx.wizard.Wizard): self.ultimaker2ReadyPage = Ultimaker2ReadyPage(self) self.lulzbotReadyPage = LulzbotReadyPage(self) - self.lulzbotToolheadPage = LulzbotToolheadSelectPage(self) - self.taz5NozzleSelectPage = Taz5NozzleSelectPage(self) - - #wx.wizard.WizardPageSimple.Chain(self.machineSelectPage, self.ultimaker2ReadyPage) + self.lulzbotFirmwarePage = LulzbotFirmwareUpdatePage(self) + self.lulzbotMiniToolheadPage = LulzbotMiniToolheadSelectPage(self) + self.lulzbotTazToolheadPage = LulzbotTazToolheadSelectPage(self) + self.lulzbotTazHotendPage = LulzbotHotendSelectPage(self) + self.lulzbotTaz5NozzleSelectPage = LulzbotTaz5NozzleSelectPage(self) + self.lulzbotMachineSelectPage = LulzbotMachineSelectPage(self) + self.lulzbotTazBedSelectPage = LulzbotTazBedSelectPage(self) + self.lulzbotTazSelectPage = LulzbotTazSelectPage(self) + + wx.wizard.WizardPageSimple.Chain(self.lulzbotMachineSelectPage, self.lulzbotMiniToolheadPage) + wx.wizard.WizardPageSimple.Chain(self.lulzbotMiniToolheadPage, self.lulzbotReadyPage) + wx.wizard.WizardPageSimple.Chain(self.lulzbotTazHotendPage, self.lulzbotTazToolheadPage) wx.wizard.WizardPageSimple.Chain(self.machineSelectPage, self.ultimakerSelectParts) wx.wizard.WizardPageSimple.Chain(self.ultimakerSelectParts, self.ultimakerFirmwareUpgradePage) wx.wizard.WizardPageSimple.Chain(self.ultimakerFirmwareUpgradePage, self.ultimakerCheckupPage) wx.wizard.WizardPageSimple.Chain(self.ultimakerCheckupPage, self.bedLevelPage) - #wx.wizard.WizardPageSimple.Chain(self.ultimakerCalibrationPage, self.ultimakerCalibrateStepsPerEPage) wx.wizard.WizardPageSimple.Chain(self.printrbotSelectType, self.otherMachineInfoPage) wx.wizard.WizardPageSimple.Chain(self.otherMachineSelectPage, self.customRepRapInfoPage) - wx.wizard.WizardPageSimple.Chain(self.machineSelectPage, self.lulzbotToolheadPage) - wx.wizard.WizardPageSimple.Chain(self.lulzbotToolheadPage, self.lulzbotReadyPage) - self.RunWizard(self.machineSelectPage) + self.RunWizard(self.lulzbotMachineSelectPage) self.Destroy() def OnPageChanging(self, e): @@ -1296,6 +1621,8 @@ class ConfigWizard(wx.wizard.Wizard): self.FindWindowById(wx.ID_BACKWARD).Enable() else: self.FindWindowById(wx.ID_BACKWARD).Disable() + if hasattr(e.GetPage(), 'OnPageShown'): + e.GetPage().OnPageShown() def OnCancel(self, e): new_machine_index = int(profile.getPreferenceFloat('active_machine'))