From 0a998eff202147b78dfc975939757b3f4254b8f1 Mon Sep 17 00:00:00 2001 From: Andre Fonteles Date: Wed, 2 Dec 2020 16:15:25 -0500 Subject: [PATCH 1/2] Added a the path of the newly created file in the success message. --- .gitignore | 1 + MainGUI.py | 12 ++++++++---- usfm2html.py | 3 +++ 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba0430d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__/ \ No newline at end of file diff --git a/MainGUI.py b/MainGUI.py index ea96113..b3e7529 100644 --- a/MainGUI.py +++ b/MainGUI.py @@ -6,6 +6,7 @@ from functools import partial from tkinter import messagebox import os.path +import webbrowser class MainGUI: @@ -55,14 +56,17 @@ def pick_file(self): self.__file_path.set(path) # Uses convert_to_html function to convert the file chosen, - # the resets the GUI. If no file has been chosen, do nothing. + # then resets the GUI. If no file has been chosen, do nothing. def convert(self): path = self.__file_path.get() + target_file = "" if(path): #If a file has been chosen, then attempt convertion - self.convert_to_html(path) - messagebox.showinfo("Success", "You HTML has been successfully generated") - self.reset() + target_file = self.convert_to_html(path) + + if(target_file): # If the HTML is generated successfuly + messagebox.showinfo("Success", "Your HTML has been generated at: \n" + target_file) + self.reset() # Resets the GUI to its original state. def reset(self): diff --git a/usfm2html.py b/usfm2html.py index 480fe24..8c15496 100755 --- a/usfm2html.py +++ b/usfm2html.py @@ -137,6 +137,9 @@ def convert_to_html(convert_file): newfile.write("") newfile.close() + return target_file + + arguments=sys.argv[1:] count_args=len(arguments) print("usfm2html: Making your output prettier since 2018\n") From 809e6538f838f0be041ce4b2afb8b4a19678950f Mon Sep 17 00:00:00 2001 From: Andre Fonteles Date: Wed, 2 Dec 2020 16:18:58 -0500 Subject: [PATCH 2/2] Added an Error message in case the HTML could not be generated --- MainGUI.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MainGUI.py b/MainGUI.py index b3e7529..8ca58d3 100644 --- a/MainGUI.py +++ b/MainGUI.py @@ -66,7 +66,9 @@ def convert(self): if(target_file): # If the HTML is generated successfuly messagebox.showinfo("Success", "Your HTML has been generated at: \n" + target_file) - self.reset() + self.reset() + else: + messagebox.showerror("Error", "Something went wrong and the file could not be generated") # Resets the GUI to its original state. def reset(self):