From b2b4bd79d1ca428f6e7ccca43f78d97b16b75ffd Mon Sep 17 00:00:00 2001 From: oleting Date: Tue, 5 Jan 2021 00:46:30 +0100 Subject: [PATCH] + fix cancel on progressbar --- gui/gui.py | 17 +++++++++++------ gui/utils.py | 5 ++++- interpreter/NassiShneidermann.py | 4 +++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/gui/gui.py b/gui/gui.py index 628b715..7776808 100644 --- a/gui/gui.py +++ b/gui/gui.py @@ -98,13 +98,18 @@ class Gui: 'You didn\'t set a name for the image, it will be named randomly.') output_name = secrets.token_hex(16) - nassi(input_path=file_path, output_path=output_path, outputname=output_name, gui=self, + path = nassi(input_path=file_path, output_path=output_path, outputname=output_name, gui=self, font_filepath=font_filepath, behaviour=exists_choice, types=types, remove_tags=modifier, comments=comments) - - fnames = output(values['-OUTPUT FOLDER-'], output_name) - sg.popup_annoying('Successfully created!', title='Created', - auto_close_duration=2, auto_close=True, text_color='green') - window['-OUTPUT FILE LIST-'].update(fnames) + if path: + fnames = output(path) + sg.popup_annoying('Successfully created!', title='Created', + auto_close_duration=2, auto_close=True, text_color='green') + window['-OUTPUT FILE LIST-'].update(fnames) + else: + fnames = output(output_path, output_name) + sg.popup_annoying('There are some images created!', title='Cancel', + auto_close_duration=2, auto_close=True, text_color='green') + window['-OUTPUT FILE LIST-'].update(fnames) except JavaSyntaxError as JsE: logging.error( diff --git a/gui/utils.py b/gui/utils.py index afe4ef6..395b514 100644 --- a/gui/utils.py +++ b/gui/utils.py @@ -24,7 +24,10 @@ def nassi(input_path: str, output_path: str, outputname: str, types, remove_tags custom_tags = {"comments" : comments, "ignore" : remove_tags, "types" : types} NSD.load_from_file(input_path, custom_tags) - NSD.convert_to_image(output_directory, on_conflict=behaviour) + cancel = NSD.convert_to_image(output_directory, on_conflict=behaviour) + + if not cancel: + return None return output_directory diff --git a/interpreter/NassiShneidermann.py b/interpreter/NassiShneidermann.py index d564b4e..0cc1400 100644 --- a/interpreter/NassiShneidermann.py +++ b/interpreter/NassiShneidermann.py @@ -62,7 +62,9 @@ class NassiShneidermanDiagram: number_of_item = 1 for scope in self.function_scopes: number_of_item += 1 - one_line_progress_meter('Progress', number_of_item, len(self.function_scopes), '-PROGRESSBAR-') + cancel = one_line_progress_meter('Progress', number_of_item, len(self.function_scopes), '-PROGRESSBAR-') + if not cancel: + return False filepath = f"{output_path}/{scope.name}" filepath = self.check_conflicts(filepath, on_conflict)