def save_preset(self): #get all the options presets = self.settings.get(['Temp_Preset']) current_screen = roboprinter.robosm.current name = next(iter(self.selected_option)) def save_new_entry(): #delete old entry if self.original_option != None: del presets[self.original_option] #save new entry presets[name] = self.selected_option[name] #save self.settings.set(['Temp_Preset'], presets) self.settings.save() #update screen self.callback(name) def cancel(): #go back to previous screen roboprinter.robosm.current = current_screen #check for duplicate names if name in presets and name != self.original_option and not self.confirm_overwrite: #make the modal screen body_text = lang.pack['Preheat']['Duplicate']['Body_Text'] + str( name) + lang.pack['Preheat']['Duplicate']['Body_Text1'] modal_screen = Modal_Question_No_Title( body_text, lang.pack['Preheat']['Duplicate']['option1'], lang.pack['Preheat']['Duplicate']['option2'], save_new_entry, cancel) #make screen roboprinter.robosm._generate_backbutton_screen( name='duplicate_error', title=lang.pack['Preheat']['Duplicate']['Title'], back_destination=current_screen, content=modal_screen) else: save_new_entry()
def get_keyboard_results(self, result): def overwrite(): Logger.info("Result is: " + str(result)) name = next(iter(self.selected_option)) temp_option = { result: { 'Extruder1': self.selected_option[name]['Extruder1'], 'Bed': self.selected_option[name]['Bed'] } } Logger.info(str(temp_option)) self.selected_option = temp_option self.name_button.title = lang.pack['Preheat']['Edit_Preset'][ 'Name'] + result roboprinter.robosm.current = 'edit_preheat' self.confirm_overwrite = True def cancel(): name = next(iter(self.selected_option)) self.show_keyboard(name) #check if the result will overwrite an existing preset preheat_settings = self.settings.get(['Temp_Preset']) if result in preheat_settings or result == lang.pack['Preheat'][ 'Edit_Preset']['Name_Default']: #make the modal screen body_text = lang.pack['Preheat']['Duplicate']['Body_Text'] + str( result) + lang.pack['Preheat']['Duplicate']['Body_Text1'] modal_screen = Modal_Question_No_Title( body_text, lang.pack['Preheat']['Duplicate']['option1'], lang.pack['Preheat']['Duplicate']['option2'], overwrite, cancel) #make screen roboprinter.robosm._generate_backbutton_screen( name='duplicate_error', title=lang.pack['Preheat']['Duplicate']['Title'], back_destination='edit_preheat', content=modal_screen) else: overwrite()
def switch_to_preheat(self, option): #get all temperature presets acceptable_selections = self.settings.get(['Temp_Preset']) #make sure the selection is a valid selection from the dictionary if option in acceptable_selections: #make the options parameters title = option temp_ext1 = acceptable_selections[option]['Extruder1'] temp_bed = acceptable_selections[option]['Bed'] body_text = '[size=40][color=#69B3E7][font=fonts/S-Core - CoreSansD55Bold.otf][b]' + title + "[/color][/b][/font]\n[size=30]" + lang.pack[ 'Preheat']['Extruder'] + str(temp_ext1) + lang.pack['Preheat'][ 'Celsius_Alone'] + "\n" + lang.pack['Preheat']['Bed'] + str( temp_bed) + lang.pack['Preheat']['Celsius_Alone'] #alter the view for the model: if self.model == "Robo C2": body_text = '[size=40][color=#69B3E7][font=fonts/S-Core - CoreSansD55Bold.otf][b]' + title + "[/color][/b][/font]\n[size=30]" + lang.pack[ 'Preheat']['Extruder'] + str( temp_ext1) + lang.pack['Preheat']['Celsius_Alone'] #these options lead to callbacks that will either set the temperature or edit the option option1 = partial(self.set_temp, extruder=temp_ext1, bed=temp_bed) option2 = partial(self.edit, option=title) option1_text = lang.pack['Preheat']['Preheat'] if self.end_point != None: option1_text = lang.pack['Preheat']['Select'] #body_text, option1_text, option2_text, option1_function, option2_function modal_screen = Modal_Question_No_Title( body_text, option1_text, lang.pack['Preheat']['Edit'], option1, option2) #make screen roboprinter.robosm._generate_backbutton_screen( name='view_preheat', title=lang.pack['Preheat']['Edit_Preset']['Select_Preset'], back_destination=self._name, content=modal_screen, backbutton_callback=self.c.update)
def reset_defaults(self, placeholder): #get the current screen back_screen = roboprinter.robosm.current def reset(): roboprinter.printer_instance._printer.commands("M502") roboprinter.printer_instance._printer.commands("M500") roboprinter.printer_instance._printer.commands("M501") #make screen to say that the variables have been reset #body_text, button_function, button_text = roboprinter.lang.pack['Button_Screen']['Default_Button'] content = Button_Screen(roboprinter.lang.pack['EEPROM']['Acknowledge_Reset']['Body_Text'], self.sm.go_back_to_main, button_text = roboprinter.lang.pack['EEPROM']['Acknowledge_Reset']['Button']) #make screen roboprinter.robosm._generate_backbutton_screen(name='ack_reset_eeprom', title = roboprinter.lang.pack['EEPROM']['Acknowledge_Reset']['Title'] , back_destination=back_screen, content=content) def cancel(): roboprinter.robosm.current = back_screen #make the confirmation screen #body_text, option1_text, option2_text, option1_function, option2_function content = Modal_Question_No_Title(roboprinter.lang.pack['EEPROM']['Reset_Confirmation']['Body_Text'], roboprinter.lang.pack['EEPROM']['Reset_Confirmation']['positive'], roboprinter.lang.pack['EEPROM']['Reset_Confirmation']['negative'], reset, cancel) #make screen roboprinter.robosm._generate_backbutton_screen(name='reset_eeprom', title = roboprinter.lang.pack['EEPROM']['Reset_Confirmation']['Title'] , back_destination=back_screen, content=content)
def mainboard_status(self, **kwargs): back_screen = self.current def refresh_screen(): title = roboprinter.lang.pack['Mainboard']['Connection_Title'] body_text = roboprinter.lang.pack['Mainboard'][ 'Connection_Body'] button_text = roboprinter.lang.pack['Mainboard'][ 'Connection_Button'] layout = Refresh_Screen(title, body_text, button_text, start_refresh=True) self._generate_backbutton_screen( name=kwargs['name'], title=kwargs['title'], back_destination=kwargs['back_destination'], content=layout) def go_back(): self.current = back_screen #make confirmation screen content = Modal_Question_No_Title( roboprinter.lang.pack['Error_Detection']['MAINBOARD'] ['Reset_Confirmation']['Body'], roboprinter.lang.pack['Error_Detection']['MAINBOARD'] ['Reset_Confirmation']['positive'], roboprinter.lang.pack['Error_Detection']['MAINBOARD'] ['Reset_Confirmation']['negative'], refresh_screen, go_back) #make screen roboprinter.robosm._generate_backbutton_screen( name='refresh_confirmation', title=roboprinter.lang.pack['Error_Detection']['MAINBOARD'] ['Reset_Confirmation']['Title'], back_destination=back_screen, content=content)
def delete_preset(self): screen = roboprinter.robosm.current def delete(): #get all the options presets = self.settings.get(['Temp_Preset']) #delete entry name = next(iter(self.selected_option)) del presets[name] #save self.settings.set(['Temp_Preset'], presets) self.settings.save() #Info Popup saying that we deleted the preset title = lang.pack['Preheat']['Delete']['Deleted'] ep = Error_Popup(name, title, callback=self.delete_callback) ep.show() def cancel(): roboprinter.robosm.current = screen #make the modal screen name = next(iter(self.selected_option)) body_text = lang.pack['Preheat']['Delete']['Body'] + str( name) + lang.pack['Preheat']['Delete']['Q_Mark'] modal_screen = Modal_Question_No_Title( body_text, lang.pack['Preheat']['Delete']['positive'], lang.pack['Preheat']['Delete']['negative'], delete, cancel) #make screen roboprinter.robosm._generate_backbutton_screen( name='delete_preset', title=lang.pack['Preheat']['Delete']['Title'], back_destination=screen, content=modal_screen)
def system_handler(self, **kwargs): option = kwargs['name'] acceptable_options = { 'Shutdown': { 'command': 'sudo shutdown -h now', 'popup': "WARNING", 'error': roboprinter.lang.pack['System']['Shutdown_Title'], 'body_text': roboprinter.lang.pack['System']['Shutdown_Body'], 'delay': 5, 'confirmation': True, 'Title': roboprinter.lang.pack['System']['Shutdown_Confirmation'] ['Title'], 'Body_Text': roboprinter.lang.pack['System']['Shutdown_Confirmation'] ['Body_Text'] }, 'Reboot': { 'command': 'sudo reboot', 'popup': "WARNING", 'error': roboprinter.lang.pack['System']['Reboot_Title'], 'body_text': roboprinter.lang.pack['System']['Reboot_Body'], 'delay': 5, 'confirmation': True, 'Title': roboprinter.lang.pack['System']['Reboot_Confirmation'] ['Title'], 'Body_Text': roboprinter.lang.pack['System']['Reboot_Confirmation'] ['Body_Text'] }, 'umount': { 'command': 'sudo umount /dev/sda1' if not 'usb_location' in session_saver.saved else 'sudo umount ' + session_saver.saved['usb_location'], 'popup': "ERROR", 'error': roboprinter.lang.pack['System']['USB_Title'], 'body_text': roboprinter.lang.pack['System']['USB_Body'], 'delay': 0.1, 'confirmation': False }, } if option in acceptable_options: def show_error(): popup = acceptable_options[option]['popup'] if popup == "WARNING": Logger.info("Showing Warning") wp = Warning_Popup( acceptable_options[option]['error'], acceptable_options[option]['body_text']) wp.show() elif popup == "ERROR": Logger.info("Showing Error") ep = Error_Popup( acceptable_options[option]['error'], acceptable_options[option]['body_text'], callback=partial( roboprinter.robosm.go_back_to_main, tab='printer_status_tab')) ep.show() Logger.info("Executing: " + acceptable_options[option]['command']) self.shell_command = acceptable_options[option]['command'] Clock.schedule_once(self.execute_function, acceptable_options[option]['delay']) def go_back(back): self.current = back if acceptable_options[option]['confirmation']: #make a confirmation screen back_screen = self.current back_function = partial(go_back, back=back_screen) content = Modal_Question_No_Title( acceptable_options[option]['Body_Text'], roboprinter.lang.pack['System']['positive'], roboprinter.lang.pack['System']['negative'], show_error, back_function) #make screen roboprinter.robosm._generate_backbutton_screen( name='view_preheat', title=acceptable_options[option]['Title'], back_destination=back_screen, content=content) else: show_error() else: Logger.info('Not an acceptable system option' + str(option))
def delete(self): current_screen = roboprinter.robosm.current def confirm_delete(): if self.isFolder: #delete the folder try: path = "/".join(self.path) #path = roboprinter.printer_instance._file_manager.path_on_disk('local', path) roboprinter.printer_instance._file_manager.remove_folder( 'local', path, recursive=True) roboprinter.robosm.go_back_to_main('files_tab') except Exception as e: Logger.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " + str(e)) traceback.print_exc() ep = Error_Popup( roboprinter.lang.pack['Files']['Error']['Title'], roboprinter.lang.pack['Files']['Error']['Body'], callback=partial(roboprinter.robosm.go_back_to_main, tab='printer_status_tab')) ep.open() #delete the file else: try: path = roboprinter.printer_instance._file_manager.path_in_storage( 'local', self.path) roboprinter.printer_instance._file_manager.remove_file( 'local', path) roboprinter.robosm.go_back_to_main('files_tab') except Exception as e: Logger.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " + str(e)) traceback.print_exc() ep = Error_Popup( roboprinter.lang.pack['Files']['Error']['Title'], roboprinter.lang.pack['Files']['Error']['Body'], callback=partial(roboprinter.robosm.go_back_to_main, tab='printer_status_tab')) ep.open() Clock.schedule_once(self.update_files, 2) def cancel(): roboprinter.robosm.current = current_screen #set variables for Folder or File title = roboprinter.lang.pack['Files']['Delete_File_Conf']['Title'] body = roboprinter.lang.pack['Files']['Delete_File_Conf']['Body'] pos = roboprinter.lang.pack['Files']['Delete_File_Conf']['positive'] neg = roboprinter.lang.pack['Files']['Delete_File_Conf']['negative'] if self.isFolder: title = roboprinter.lang.pack['Files']['Delete_Folder_Conf'][ 'Title'] body = roboprinter.lang.pack['Files']['Delete_Folder_Conf']['Body'] #make confirmation screen content = Modal_Question_No_Title(body, pos, neg, confirm_delete, cancel) #make screen roboprinter.robosm._generate_backbutton_screen( name='delete_confirmation', title=title, back_destination=current_screen, content=content)