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

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

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -