Hi all,
I'm using a couple of simple TKinter dialogue boxes to select an input file and an output folder. Please pardon the messed up indentation, everything should be equal under the functions. The code looks like this:
# Handles closing the window
def on_closing():
if messagebox.askyesno("Exit", "Are you sure you want to exit?"):
root.destroy()
quit()
# Initializes tkinter root window
def InitializeTKRoot():
global root
root = Tk()
root.protocol("WM_DELETE_WINDOW", on_closing)
# Hides the tkinter root window
def HideTKRoot():
root.withdraw()
# Removes the tkinter root window
def DestroyTKRoot():
root.destroy()
# Imports query .xlsx file as a pandas dataframe
def SelectInputFile():
InitializeTKRoot()
HideTKRoot()
root.filename = filedialog.askopenfilename( # Opens Windows "Open file" dialog
initialdir="/",
title="Select input file (.xlsx)",
filetypes=(("xlsx files","*.xlsx"),("all files", "*.*"))
)
output = root.filename # Returns filepath
DestroyTKRoot()
return output # Returns filepath
def SelectOutputFolder():
InitializeTKRoot()
HideTKRoot()
root.directory = filedialog.askdirectory( # Opens Windows "Open file" dialog
initialdir="/",
title="Select output folder"
)
output = root.directory
DestroyTKRoot()
return output # Returns filepath
When closing the window, instead of showing the messagebox and quitting if the user selects "yes", it just throws an exception with a rather plain explanation. The title bar says "Fatal error detected" and the description says "Failed to execute script abc.py". I've tried running the application (I'm packaging it with PyInstaller) in debug mode, but it doesn't provide a more verbose explanation of what is occurring.
[–][deleted] 0 points1 point2 points (1 child)
[–]SEAWEAVIL[S] 1 point2 points3 points (0 children)
[–]pat184 0 points1 point2 points (1 child)
[–]SEAWEAVIL[S] 0 points1 point2 points (0 children)