diff --git a/ks_includes/config.py b/ks_includes/config.py index 71d17cc4..b93065af 100644 --- a/ks_includes/config.py +++ b/ks_includes/config.py @@ -161,7 +161,7 @@ class KlipperScreenConfig: bools = ( 'invert_x', 'invert_y', 'invert_z', '24htime', 'only_heaters', 'show_cursor', 'confirm_estop', 'autoclose_popups', 'use_dpms', 'use_default_menu', 'side_macro_shortcut', 'use-matchbox-keyboard', - 'show_heater_power', "show_scroll_steppers", "auto_open_extrude" + 'show_heater_power', "show_scroll_steppers", "auto_open_extrude" , 'onboarding' ) strs = ( 'default_printer', 'language', 'print_sort_dir', 'theme', 'screen_blanking_printing', 'font_size', @@ -319,6 +319,7 @@ class KlipperScreenConfig: {"print_sort_dir": {"section": "main", "type": None, "value": "name_asc"}}, {"print_view": {"section": "main", "type": None, "value": "thumbs"}}, {"language": {"section": "main", "name": _("Language"), "type": None, "value": "system_lang"}}, + {"onboarding": {"section": "main", "type": "binary", "value": "False"}}, ] self.configurable_options.extend(panel_options) diff --git a/panels/onboarding.py b/panels/onboarding.py new file mode 100644 index 00000000..3c1daf54 --- /dev/null +++ b/panels/onboarding.py @@ -0,0 +1,69 @@ +import logging +import os +import gi + +gi.require_version("Gtk", "3.0") +from gi.repository import Gtk, Pango +from ks_includes.screen_panel import ScreenPanel + + +class Panel(ScreenPanel): + + def __init__(self, screen, title): + title = title or _('Welcome') + super().__init__(screen, title) + + buttons = [ + {"name": _("Next"), "response": Gtk.ResponseType.YES, "style": 'dialog-secondary'} + ] + + image = self._gtk.Image( + "retainer", self._gtk.content_width * 0.3, self._gtk.content_height * 0.5 + ) + start_text = _("1. For first use, refer to the accompanying diagram to disassemble the fixed components of the X, Y, and Z axes.") + space = "\n\n" + end_text = _("2. Once the disassembly is complete, click the 'Next' button to proceed.") + label = Gtk.Label(hexpand=True, vexpand=True, wrap=True, wrap_mode=Pango.WrapMode.WORD_CHAR) + label.set_markup(f"{start_text + space + end_text}\n") + box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, vexpand=True) + image.set_margin_start(60) + image.set_margin_top(80) + box.pack_start(image, False, True, 0) + box.pack_start(label, False, False, 20) + + self._gtk.Dialog(f'Welcome', buttons, box, self.confirm_print_response) + + def create_raise_platform(self): + buttons = [ + {"name": _("Raise Platform"), "response": Gtk.ResponseType.OK}, + {"name": _("Finish"), "response": Gtk.ResponseType.APPLY, "style": 'dialog-secondary'} + ] + + image = self._gtk.Image( + "take_out", self._gtk.content_width * 0.3, self._gtk.content_height * 0.5 + ) + + start_text = _("1. Ensure that all fixed components have been properly removed before proceeding.") + center_text = _("2. Press the 'Raise Platform' button to lift the platform and remove the items underneath.") + end_text = _("3. Once the operation is complete, click the \'Finish\' button to conclude the process.") + space = "\n\n" + label = Gtk.Label(hexpand=True, vexpand=True, wrap=True, wrap_mode=Pango.WrapMode.WORD_CHAR) + label.set_markup(f"{start_text + space + center_text + space + end_text}\n") + box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, vexpand=True) + image.set_margin_start(60) + image.set_margin_top(80) + box.pack_start(image, False, True, 0) + box.pack_start(label, False, False, 20) + + self._gtk.Dialog(f'Test', buttons, box, self.confirm_print_response) + + def confirm_print_response(self, dialog, response_id): + if response_id == Gtk.ResponseType.YES: + self._gtk.remove_dialog(dialog) + self.create_raise_platform() + elif response_id == Gtk.ResponseType.OK: + self._screen._ws.klippy.gcode_script("SET_KINEMATIC_POSITION Z=5\nG28") + elif response_id == Gtk.ResponseType.APPLY: + self._screen.show_panel("main_menu", remove_all=True, items=self._config.get_menu_items("__main")) + self._config.set("main", "onboarding", "False") + self._config.save_user_config_options() diff --git a/screen.py b/screen.py index eae28b92..99562310 100755 --- a/screen.py +++ b/screen.py @@ -722,6 +722,9 @@ class KlipperScreen(Gtk.Window): def show_language_select(self, widget=None): self.show_panel("language_select", remove_all=True) + def show_onboarding(self, widget=None): + self.show_panel("onboarding", remove_all=True) + def show_printer_select(self, widget=None): if 'printer_select' not in self._cur_panels: self.base_panel.show_heaters(False) @@ -788,8 +791,12 @@ class KlipperScreen(Gtk.Window): self.printer.state = "not ready" return self.files.refresh_files() - self.show_panel("main_menu", remove_all=True, items=self._config.get_menu_items("__main")) - self._ws.klippy.gcode_script("UPDATE_DELAYED_GCODE ID=_CHECK_POWER_LOSS_RECOVERY DURATION=0.1") + guided = self._config.get_main_config().get("onboarding", False) + if guided == 'True': + self.show_onboarding() + else: + self.show_panel("main_menu", remove_all=True, items=self._config.get_menu_items("__main")) + self._ws.klippy.gcode_script("UPDATE_DELAYED_GCODE ID=_CHECK_POWER_LOSS_RECOVERY DURATION=0.1") def state_startup(self): self.printer_initializing(_("Klipper is attempting to start")) diff --git a/styles/dark/images/retainer.svg b/styles/dark/images/retainer.svg new file mode 100644 index 00000000..b31fc957 --- /dev/null +++ b/styles/dark/images/retainer.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/styles/dark/images/take_out.svg b/styles/dark/images/take_out.svg new file mode 100644 index 00000000..2c91f69b --- /dev/null +++ b/styles/dark/images/take_out.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + +