python - How to avoid unhandled exception in Tkinter? -


i'm trying exit program when user decides close tkinter filedialog menu without selecting file open. however, although program exits keep getting following message before terminates:

the debugged program raised exception unhandled filenotfounderror [errno2] no such file or directory

i thought code have below handle though, maybe wrong? or advice appreciated.

if root.filename none:     sys.exit(0) else:     pass 

when doesn't return filename (the user canceled dialog), filedialog return empty string (''), not none. use instead:

if not root.filename:     ... 

Comments

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Using jquery append to add option values into a select element not working -

javascript - Restarting Supervisor and effect on FlaskSocketIO -