Skip to content

Commit 3b85ff2

Browse files
authored
Merge pull request #47 from iansan5653/fix/task_remains_open_after_closing
Fix process failing to exit when the user closes
2 parents c158706 + 099e676 commit 3b85ff2

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

code/main.py

+4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
from mcta_processing import transform_and_save_mcta_output
1212
import scoring
1313
import user_interface
14+
import sys
1415

1516
user_input = user_interface.MainWindow()
17+
if (user_input.cancelled):
18+
sys.exit(0)
19+
1620
input_folder = user_input.input_folder
1721
image_paths = file_handling.filter_images(
1822
file_handling.list_file_paths(input_folder))

code/user_interface.py

+8
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ class MainWindow:
453453
output_mcta: bool
454454
debug_mode: bool = False
455455
form_variant: FormVariantSelection
456+
cancelled: bool = False
456457

457458
def __init__(self):
458459
app: tk.Tk = tk.Tk()
@@ -462,6 +463,8 @@ def __init__(self):
462463
iconpath = str(Path(__file__).parent / "assets" / "icon.ico")
463464
app.iconbitmap(iconpath)
464465

466+
app.protocol("WM_DELETE_WINDOW", self.__on_close)
467+
465468
self.__input_folder_picker = InputFolderPickerWidget(
466469
app, self.__on_update)
467470
self.__answer_key_picker = AnswerKeyPickerWidget(app, self.__on_update)
@@ -616,5 +619,10 @@ def __show_sheet(self):
616619
"multiple_choice_sheet_150q.pdf")
617620
subprocess.Popen([helpfile], shell=True)
618621

622+
def __on_close(self):
623+
self.__app.destroy()
624+
self.__ready_to_continue.set(1)
625+
self.cancelled = True
626+
619627
def create_and_pack_progress(self, maximum: int) -> ProgressTrackerWidget:
620628
return ProgressTrackerWidget(self.__app, maximum)

0 commit comments

Comments
 (0)