Python Tkinter Tkfiledialog
in short, what's the difference between tkFileDialog.asksaveasfile and tkFileDialog.asksaveasfilename I could not understand from the build in docs
Solution 1:
asksaveasfile
asks the user for a file, then opens that file in write mode and returns it to you so you can write in it.
asksaveasfilename
asks the user for a file, then returns that file's name. No file is opened; if you want to write to the file, you'll have to open it yourself.
asksaveasfilename
might be preferred over asksaveasfile
if you want to do something fancier to the file than just writing data to it. For instance, you might want to first copy the file to another directory as a backup. In which case, you'd prefer to get just the file name so you can perform the copy without having to worry about whether having the file open will cause the copy to fail.
Post a Comment for "Python Tkinter Tkfiledialog"