def on_pre_enter(self): try: self.is_active = True self.configuration_api = self.api.get_configuration_api() dripper_type = self.configuration_api.get_dripper_type() self.ids.dripper_type_selector.selected = dripper_type self.dripper_type_changed(None, dripper_type) self.emulated_settings.drips_per_mm = self.configuration_api.get_dripper_drips_per_mm( ) self.emulated_settings.drips_per_second = self.configuration_api.get_dripper_emulated_drips_per_second( ) self.circut_settings.drips_per_mm = self.configuration_api.get_dripper_drips_per_mm( ) self.circut_visuals.target_height = str( self.circut_setup.test_height) self.photo_settings.photo_zaxis_delay = self.configuration_api.get_dripper_photo_zaxis_delay( ) except: raise ep = ErrorPopup(title=_("Error"), text=_("No Peachy Printer Detected")) ep.open() App.get_running_app().root.current = 'main_ui'
def on_pre_enter(self): try: self.configuration_api = self.api.get_configuration_api() except Exception as ex: import traceback traceback.print_exc() ep = ErrorPopup(title_source=_("Error"), text=_("No Peachy Printer Detected"), details="%s\n%s" % (type(ex), ex)) ep.open() App.get_running_app().root.current = 'main_ui'
def turn_on(self): self.is_active = True try: self.calibration_api = self.api.get_calibration_api() self.calibration_api.show_point([0.5, 0.5, 0.0]) except Exception as ex: import traceback traceback.print_exc() ep = ErrorPopup(title_source=_("Error"), text=_("No Peachy Printer Detected"), details="%s\n%s" % (type(ex), ex)) ep.open() App.get_running_app().root.current = 'mainui' self._switch_to_default_panel()
def ready_check(self, args): self.label.text_source = _( "Checking for readiness, do not shutdown or restart your computer or disconnect." ) if self.firmware_api.is_ready(): Logger.info("Printer is ready") self.label.text_source = _( "Updating, do not shutdown or restart your computer or disconnect." ) self.firmware_api.update_firmware(self.complete_call_back) else: Logger.info("Printer is not ready, checking again.") Clock.schedule_once(self.ready_check, self.check_rate)
def __init__(self, text=None, details=None, title_source=None, **kwargs): if text is None: self.text = _("Bad Stuff Happened") else: self.text = text if title_source is None: self.title_source = _("No Title") else: self.title_source = title_source if details is None: self.details = "" else: self.details = details super(ErrorPopup, self).__init__(**kwargs)
def __init__(self, text=None, details=None, title_source=None, **kwargs): if text is None: self.text = _('Bad Stuff Happened') else: self.text = text if title_source is None: self.title_source = _("No Title") else: self.title_source = title_source if details is None: self.details = "" else: self.details = details super(ErrorPopup, self).__init__(**kwargs)
def _complete_fail(self, *args): self.image.anim_delay = -1 self.label.text_source = _( "Firmware update failed, please disconnect the printer restart the software and try again." ) self._complete_button.on_release = self.exit self.window.add_widget(self._complete_button)
def turn_on(self): self.is_active = True try: self.calibration_api = self.api.get_calibration_api() self.calibration_api.subscribe_to_status( self.status_bar.update_message) self.calibration_api.show_point([0.5, 0.5, 0.0]) except Exception as ex: import traceback traceback.print_exc() ep = ErrorPopup(title_source=_("Error"), text=_("No Peachy Printer Detected"), details="%s\n%s" % (type(ex), ex)) ep.open() App.get_running_app().root.current = 'main_ui' self._switch_to_default_panel()
def switch_lang(self, lang): Logger.info("Using Language Locale: %s" % self.lang) locale_dir = join(dirname(__file__), 'resources', 'il8n', 'locales') locales = gettext.translation('peachyprinter', locale_dir, languages=[self.lang]) self.translator = locales.ugettext if hasattr(self, 'settings'): self.settings.interface.menu.close_button.text = self.translation(_("Close"))
def _complete_success(self, *args): self.label.text_source = _( "Firmware update successful. Please disconnect and reconnect your printer." ) self.image.source = 'resources/images/firmware_out_in_512x512.zip' self.image.anim_delay = 1.0 / 15.0 Clock.schedule_once(self._check_for_peachy, 0.5)
def connect_to_printer(self): try: self.setting_translation.load_config(self.config) self.config.add_callback(self.setting_translation.update_setting) self.api.get_configuration_api().get_current_config() return True except MissingPrinterException: return False except Exception as ex: fail_box = BoxLayout(orientation="vertical") pop_message = I18NLabel(text_source=_("An Error has Occured"), size_hint_y=None, height=self.label_height,) pop_error = I18NLabel(text_source=str(ex)) pop_exit = I18NButton(text_source=_("Exit"), size_hint_y=None, height=self.button_height, on_release=self.exit_app) fail_box.add_widget(pop_message) fail_box.add_widget(pop_error) fail_box.add_widget(pop_exit) return fail_box
def _update_status(self, arg): data = self.print_api.get_status() if 'status' in data: self.status = data['status'] if 'model_height' in data: self.model_height = data['model_height'] if 'start_time' in data: self.start_time = data['start_time'] if 'drips' in data: self.drips = data['drips'] self.ids.printer_animation.drips = data['drips'] if 'height' in data: self.print_height = data['height'] if 'drips_per_second' in data: self.drips_per_second = data['drips_per_second'] if 'errors' in data: self.errors = data['errors'] if 'waiting_for_drips' in data: self.ids.printer_animation.waiting_for_drips = data['waiting_for_drips'] self.waiting_for_drips = str(data['waiting_for_drips']) if 'elapsed_time' in data: self.elapsed_time = self.time_delta_format(data['elapsed_time']) if 'current_layer' in data: self.current_layer = data['current_layer'] if 'skipped_layers' in data: self.skipped_layers = data['skipped_layers'] if 'drip_history' in data: self.ids.printer_animation.drip_history = data['drip_history'] if 'axis' in data: self.ids.printer_animation.axis_history = data['axis'] Clock.unschedule(self._update_status) if self.status == 'Complete': self.ids.printer_animation.animation_stop() self.play_complete_sound() if (App.get_running_app().last_print.print_type is "file" and len(self._filenames) > 0): self._wait_and_print_next() else: self.ids.navigate_button.text_source = _("Print Complete") elif self.status == 'Failed': self.ids.printer_animation.animation_stop() self.play_failed_sound() self.ids.navigate_button.text_source = _("Print Failed") else: Clock.schedule_once(self._update_status, self.refresh_rate)
def on_pre_enter(self): try: self.is_active = True self.configuration_api = self.api.get_configuration_api() dripper_type = self.configuration_api.get_dripper_type() self.ids.dripper_type_selector.selected = dripper_type self.dripper_type_changed(None, dripper_type) self.emulated_settings.drips_per_mm = self.configuration_api.get_dripper_drips_per_mm() self.circut_settings.drips_per_mm = self.configuration_api.get_dripper_drips_per_mm() self.circut_visuals.target_height = str(self.circut_setup.test_height) self.photo_settings.photo_zaxis_delay = self.configuration_api.get_dripper_photo_zaxis_delay() except: raise ep = ErrorPopup(title=_("Error"), text=_("No Peachy Printer Detected")) ep.open() App.get_running_app().root.current = 'mainui'
def _get_display_version(self, reported_version): if self.firmware_api.is_ready(): return _('Bootloader') elif reported_version == '': return self._bootloader_required() elif self._get_revision_from_verison(reported_version) < 238: return self._bootloader_required() else: return reported_version
def __init__(self, api, **kwargs): super(FirmwareUpdateUI, self).__init__(**kwargs) self.api = api self.check_rate = 1.0 / 4.0 app = App.get_running_app() self._complete_button = I18NButton(text_source=_("Continue"), on_release=self.close, size_hint_y=None, height=app.button_height)
def print_files(self, filenames, start_height): try: start_height = float(start_height) except: start_height = 0.0 self.print_options = [self._print_files, filenames, {'start_height': start_height}] popup = LaserWarningPopup(title=_('Laser Safety Notice'), size_hint=(0.6, 0.6)) popup.bind(on_dismiss=self.is_safe) popup.open()
def show_disclaimer(self, *args): accepted_disclaimer = Config.getdefault('internal', 'disclaimer', False) if not accepted_disclaimer: self._disclaimer = I18NPopup( title_source=_("Disclaimer"), content=Disclaimer(self.accept_disclaimer, self.reject_disclaimer, ), size_hint=(0.9, 0.9), auto_dismiss=False) self._disclaimer.open()
def show_load(self): self.last_directory = Config.getdefault('internal', 'last_directory', self.last_directory) content = LoadDialog(load=self.load, cancel=self.dismiss_popup, last_directory=self.last_directory) self._popup = I18NPopup(title_source=_("Load file"), content=content, size_hint=(0.9, 0.9)) self._popup.open()
def switch_lang(self, lang): Logger.info("Using Language Locale: %s" % self.lang) locale_dir = join(dirname(__file__), 'resources', 'il8n', 'locales') locales = gettext.translation('peachyprinter', locale_dir, languages=[self.lang]) self.translator = locales.ugettext if hasattr(self, 'settings'): self.settings.interface.menu.close_button.text = self.translation( _("Close"))
def __init__(self, **kwargs): super(TestPatternPanel, self).__init__(**kwargs) self.loaded = False self.friendly_names = { "Square": _("Square"), "Twitch": _("Twitch"), "Damping Test": _("Damping"), "Memory Hourglass": _("Hourglass"), "NESW": _("NESW"), "Circle": _("Circle"), "Hilbert Space Filling Curve": _("Hilbert"), "Spiral": _("Spiral"), }
def show_disclaimer(self, *args): accepted_disclaimer = Config.getdefault('internal', 'disclaimer', False) if not accepted_disclaimer: self._disclaimer = I18NPopup(title_source=_("Disclaimer"), content=Disclaimer( self.accept_disclaimer, self.reject_disclaimer, ), size_hint=(0.9, 0.9), auto_dismiss=False) self._disclaimer.open()
def build(self): self.icon = os.path.join(os.path.dirname(__file__), 'resources', 'peachy.png') self.settings_cls = SettingsWithSidebar try: self.setting_translation.load_config(self.config) self.config.add_callback(self.setting_translation.update_setting) except MissingPrinterException: fail_box = BoxLayout(orientation="vertical") pop_message = I18NLabel(text_source=_("Please connect your peachy printer before starting the software")) pop_exit = I18NButton(text_source=_("Exit"), size_hint_y=None, height=30, on_release=self.exit_app) fail_box.add_widget(pop_message) fail_box.add_widget(pop_exit) return fail_box except Exception as ex: fail_box = BoxLayout(orientation="vertical") pop_message = I18NLabel(text_source=_("An Error has Occured"), size_hint_y=None, height=self.label_height,) pop_error = I18NLabel(text_source=str(ex)) pop_exit = I18NButton(text_source=_("Exit"), size_hint_y=None, height=self.button_height, on_release=self.exit_app) fail_box.add_widget(pop_message) fail_box.add_widget(pop_error) fail_box.add_widget(pop_exit) return fail_box self.manager = MyScreenManager(self.api, self.setting_translation) return self.manager
def connect_to_printer(self): try: self.setting_translation.load_config(self.config) self.config.add_callback(self.setting_translation.update_setting) self.api.get_configuration_api().get_current_config() return True except MissingPrinterException: return False except Exception as ex: fail_box = BoxLayout(orientation="vertical") pop_message = I18NLabel( text_source=_("An Error has Occured"), size_hint_y=None, height=self.label_height, ) pop_error = I18NLabel(text_source=str(ex)) pop_exit = I18NButton(text_source=_("Exit"), size_hint_y=None, height=self.button_height, on_release=self.exit_app) fail_box.add_widget(pop_message) fail_box.add_widget(pop_error) fail_box.add_widget(pop_exit) return fail_box
def restart(self): Clock.unschedule(self._update_status) self.ids.printer_animation.animation_stop() if self.dripper_setting: self.ids.dripper_grid.remove_widget(self.dripper_setting) self.dripper_setting = None if self.print_api: self.print_api.close() self.print_api = None self.ids.navigate_button.text_source = _('Cancel Print') self.ids.navigate_button.background_color = [2.0, 0.0, 0.0, 1.0] last_print = App.get_running_app().last_print if last_print.print_type is "file": self.print_file(last_print.source, self.return_to) elif last_print.print_type is "test_print": generator = self.api.get_test_print_api().get_test_print(*last_print.source) self.print_generator(generator, self.return_to) else: raise("Unsupported Print Type %s" % last_print.print_type)
def restart(self): Clock.unschedule(self._update_status) self.ids.printer_animation.animation_stop() if self.dripper_setting: self.ids.dripper_grid.remove_widget(self.dripper_setting) self.dripper_setting = None if self.print_api: self.print_api.close() self.print_api = None self.ids.navigate_button.text_source = _('Cancel Print') last_print = App.get_running_app().last_print if last_print.print_type is "file": self.print_files(last_print.source, self.return_to) elif last_print.print_type is "test_print": generator = self.api.get_test_print_api().get_test_print(*last_print.source) self.print_generator(generator, self.return_to) elif last_print.print_type is "cure_test_print": generator = self.api.get_configuration_api().get_cure_test(*last_print.source) self.print_generator(generator, self.return_to) else: raise("Unsupported Print Type %s" % last_print.print_type)
def print_file(self, *args, **kwargs): self.print_options = [self._print_file, args, kwargs] popup = LaserWarningPopup(title=_('Laser Safety Notice'), size_hint=(0.6, 0.6)) popup.bind(on_dismiss=self.is_safe) popup.open()
def on_printer_point(self, instance, value): self.printer_point_emphasis = False self.printer_point_text = _('Printer Posisition || ') + 'X: %.1f, Y: %.1f' % ((value[0] * 200) - 100, (value[1] * 200) - 100)
def build_settings(self, settings): self.setting_translation.refresh_settings(settings, self.config) settings.interface.menu.close_button.text = self.translation( _("Close"))
def on_pre_enter(self): for (title, value) in self.parent.setting_translation.get_settings().items(): self.settings_popup.add_setting(ListElement(title=title, value=value)) self.ids.navigate_button.text_source = _('Cancel Print') self.ids.navigate_button.background_color = [2.0, 0.0, 0.0, 1.0]
def on_printer_point(self, instance, value): self.printer_point_emphasis = False self.printer_point_text = _( 'Printer Posisition || ') + 'X: %.1f, Y: %.1f' % ( (value[0] * 200) - 100, (value[1] * 200) - 100)
def build(self): model = 'resources/objects/Simple5Sided180TwistVaseBETA.obj' text_source = _('Some Text') return I18NObjImageButton(model=model, text_source=text_source)
def build_settings(self, settings): self.setting_translation.refresh_settings(settings, self.config) settings.interface.menu.close_button.text = self.translation(_("Close"))
def on_pre_enter(self): for (title, value) in self.parent.setting_translation.get_settings().items(): self.settings_popup.add_setting(ListElement(title=title, value=value)) self.ids.navigate_button.text_source = _('Cancel Print')
def _bootloader_required(self): self.update_button.parent.remove_widget(self.update_button) FirmwareManualBootloaderPopup().open() return _('Unsupported')