From: Youness Alaoui Date: Wed, 29 Jul 2015 21:21:09 +0000 (-0400) Subject: Make a new wizard for changing the toolhead and call it from machine settings X-Git-Tag: lulzbot-15.02.1-2.01~56^2~14 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=25fdb3f70b123321fbf83f21cb3108baa2bddb87;p=cura.git Make a new wizard for changing the toolhead and call it from machine settings --- diff --git a/Cura/gui/configWizard.py b/Cura/gui/configWizard.py index 31de4859..085bbd59 100644 --- a/Cura/gui/configWizard.py +++ b/Cura/gui/configWizard.py @@ -1203,9 +1203,10 @@ class LulzbotToolheadSelectPage(InfoPage): webbrowser.open(LulzbotMiniToolheadSelectPage.url) class LulzbotMiniToolheadSelectPage(LulzbotToolheadSelectPage): - def __init__(self, parent): + def __init__(self, parent, allowBack = True): super(LulzbotMiniToolheadSelectPage, self).__init__(parent, _("LulzBot Mini Toolhead Selection")) + self.allowBack = allowBack self.panel = self.AddPanel() image_size=(LulzbotMachineSelectPage.IMAGE_WIDTH, LulzbotMachineSelectPage.IMAGE_HEIGHT) self.standard = self.AddImageButton(self.panel, 0, 0, _('Single Extruder v2'), @@ -1215,6 +1216,9 @@ class LulzbotMiniToolheadSelectPage(LulzbotToolheadSelectPage): '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') @@ -1316,9 +1320,10 @@ class LulzbotTazToolheadSelectPage(LulzbotToolheadSelectPage): class LulzbotHotendSelectPage(LulzbotToolheadSelectPage): - def __init__(self, parent): + def __init__(self, parent, allowBack = True): super(LulzbotHotendSelectPage, self).__init__(parent, _("LulzBot Toolhead Hotend 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 Hotends)'), @@ -1328,6 +1333,9 @@ class LulzbotHotendSelectPage(LulzbotToolheadSelectPage): '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) @@ -1366,6 +1374,53 @@ class LulzbotTaz5NozzleSelectPage(LulzbotToolheadSelectPage): profile.putMachineSetting('machine_name', 'LulzBot TAZ 5 (0.5 nozzle)') profile.putMachineSetting('machine_type', 'lulzbot_TAZ_5_05nozzle') +class LulzbotChangeToolheadWizard(wx.wizard.Wizard): + def __init__(self): + super(LulzbotChangeToolheadWizard, self).__init__(None, -1, _("Change Lulzbot Toolhead 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.lulzbotMiniToolheadPage = LulzbotMiniToolheadSelectPage(self, False) + self.lulzbotTazToolheadPage = LulzbotTazToolheadSelectPage(self) + self.lulzbotTazHotendPage = LulzbotHotendSelectPage(self, False) + self.lulzbotTaz5NozzleSelectPage = LulzbotTaz5NozzleSelectPage(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() + + 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): super(ConfigWizard, self).__init__(None, -1, _("Configuration Wizard")) diff --git a/Cura/gui/preferencesDialog.py b/Cura/gui/preferencesDialog.py index fa7564aa..883ce8eb 100644 --- a/Cura/gui/preferencesDialog.py +++ b/Cura/gui/preferencesDialog.py @@ -125,7 +125,8 @@ class machineSettingsDialog(wx.Dialog): printer_type = profile.getMachineSetting('machine_type', idx) if printer_type.startswith('lulzbot_'): configBase.TitleRow(right, _("Toolhead")) - configBase.ToolheadRow(right, 'toolhead', index=idx) + row = configBase.ToolheadRow(right, 'toolhead', index=idx) + row.button.Bind(wx.EVT_BUTTON, self.OnChangeToolheadButton) configBase.TitleRow(right, _("Printer head size")) configBase.SettingRow(right, 'extruder_head_size_min_x', index=idx) @@ -170,6 +171,22 @@ class machineSettingsDialog(wx.Dialog): main.Fit() self.Fit() + def OnChangeToolheadButton(self, e): + self.Hide() + self.parent.Hide() + old_active = int(profile.getPreferenceFloat('active_machine')) + profile.setActiveMachine(self.nb.GetSelection()) + configWizard.LulzbotChangeToolheadWizard() + profile.setActiveMachine(old_active) + self.parent.Show() + self.parent.reloadSettingPanels() + self.parent.updateMachineMenu() + + prefDialog = machineSettingsDialog(self.parent) + prefDialog.Centre() + prefDialog.Show() + wx.CallAfter(self.Close) + def OnAddMachine(self, e): self.Hide() self.parent.Hide()