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
Post a Comment