def update_status(self): ok_to_submit = True new_status = "" input_folder = self.__input_folder_picker.selection if input_folder is None: new_status += "❌ Input folder is required.\n" ok_to_submit = False else: self.input_folder = input_folder images = file_handling.filter_images( file_handling.list_file_paths(input_folder)) if len(images) == 0: new_status += "❌ No image files found in selected input folder.\n" ok_to_submit = False else: new_status += f"✔ Input folder selected. {len(images)} image files found.\n" output_folder = self.__output_folder_picker.selection if output_folder is None: new_status += "❌ Output folder is required.\n" ok_to_submit = False else: self.output_folder = output_folder new_status += f"✔ Output folder selected.\n" keys_file = self.__answer_key_picker.selection if keys_file: if scoring.verify_answer_key_sheet(keys_file): self.keys_file = keys_file new_status += f"✔ Selected answer keys file appears to be valid.\n" else: self.keys_file = None new_status += f"❌ Selected answer keys file is not valid.\n" ok_to_submit = False arrangement_file = self.__key_arrangement_picker.selection if arrangement_file: if scoring.verify_answer_key_sheet(arrangement_file): self.arrangement_file = arrangement_file new_status += f"✔ Selected key arrangement file appears to be valid.\n" else: self.arrangement_file = None new_status += f"❌ Selected key arrangement file is not valid.\n" ok_to_submit = False self.multi_answers_as_f = bool( self.__multi_answers_as_f_checkbox.checked.get()) if self.multi_answers_as_f: new_status += f"Questions with multiple answers selected will be output as 'F'.\n" else: new_status += f"Questions with multiple answers selected will be output in '[A|B]' form.\n" self.empty_answers_as_g = bool( self.__empty_answers_as_g_checkbox.checked.get()) if self.empty_answers_as_g: new_status += f"Unanswered questions will be output as 'G'.\n" else: new_status += f"Unanswered questions will be left as blank cells.\n" self.sort_results = bool(self.__sort_results_checkbox.checked.get()) if self.sort_results: new_status += f"Results will be sorted by name.\n" else: new_status += f"Results will be left in original order.\n" if self.__toggle_sort_count > 15: new_status += "WARNING: Debug mode enabled. Restart to disable." self.debug_mode = True self.__status_text.set(new_status) if ok_to_submit: self.__confirm_button.configure(state=tk.NORMAL) return ok_to_submit
import file_handling import grid_info as grid_i import user_interface import sys from process_input import process_input from datetime import datetime user_input = user_interface.MainWindow() if (user_input.cancelled): sys.exit(0) input_folder = user_input.input_folder image_paths = file_handling.filter_images( file_handling.list_file_paths(input_folder)) output_folder = user_input.output_folder multi_answers_as_f = user_input.multi_answers_as_f empty_answers_as_g = user_input.empty_answers_as_g keys_file = user_input.keys_file arrangement_file = user_input.arrangement_map sort_results = user_input.sort_results output_mcta = user_input.output_mcta debug_mode_on = user_input.debug_mode form_variant = grid_i.form_150q if user_input.form_variant == user_interface.FormVariantSelection.VARIANT_150_Q else grid_i.form_75q progress_tracker = user_input.create_and_pack_progress( maximum=len(image_paths)) files_timestamp = datetime.now().replace(microsecond=0) process_input(image_paths, output_folder, multi_answers_as_f, empty_answers_as_g, keys_file, arrangement_file, sort_results, output_mcta, debug_mode_on, form_variant, progress_tracker, files_timestamp)
def __on_update(self): ok_to_submit = True new_status = "" input_folder = self.__input_folder_picker.folder if input_folder is None: new_status += "❌ Input folder is required.\n" ok_to_submit = False else: self.input_folder = input_folder images = file_handling.filter_images( file_handling.list_file_paths(input_folder)) if len(images) == 0: new_status += "❌ No image files found in selected input folder.\n" ok_to_submit = False else: new_status += f"✔ Input folder selected. {len(images)} image files found.\n" self.form_variant = self.__input_folder_picker.form_variant if self.form_variant == FormVariantSelection.VARIANT_75_Q: new_status += "Using 75-question form variant.\n" elif self.form_variant == FormVariantSelection.VARIANT_150_Q: new_status += "Using 150-question form variant.\n" output_folder = self.__output_folder_picker.folder if output_folder is None: new_status += "❌ Output folder is required.\n" ok_to_submit = False else: self.output_folder = output_folder new_status += f"✔ Output folder selected.\n" keys_file = self.__answer_key_picker.file self.keys_file = None if keys_file: if scoring.verify_answer_key_sheet(keys_file): self.keys_file = keys_file new_status += f"✔ Selected answer keys file appears to be valid.\n" else: new_status += f"❌ Selected answer keys file is not valid.\n" ok_to_submit = False arrangement_map = self.__arrangement_map_picker.file self.arrangement_map = None if arrangement_map: if scoring.verify_answer_key_sheet(arrangement_map): self.arrangement_map = arrangement_map new_status += f"✔ Selected key arrangement file appears to be valid.\n" else: new_status += f"❌ Selected key arrangement file is not valid.\n" ok_to_submit = False self.multi_answers_as_f = self.__input_folder_picker.multi_answers_as_f if self.multi_answers_as_f: new_status += f"Questions with multiple answers selected will be output as 'F'.\n" else: new_status += f"Questions with multiple answers selected will be output in '[A|B]' form.\n" self.empty_answers_as_g = self.__input_folder_picker.empty_answers_as_g if self.empty_answers_as_g: new_status += f"Unanswered questions will be output as 'G'.\n" else: new_status += f"Unanswered questions will be left as blank cells.\n" self.sort_results = self.__output_folder_picker.sort_results if self.sort_results: new_status += f"Results will be sorted by name.\n" else: new_status += f"Input sort order will be maintained.\n" if self.__output_folder_picker.sort_toggle_count > 15: new_status += "WARNING: Debug mode enabled. Restart to disable." self.debug_mode = True self.__status_text.set(new_status) if ok_to_submit: self.__confirm_button.configure(state=tk.NORMAL) return ok_to_submit