Apart from selecting existing files and directories, it is also possible to create a new file using Tkinter dialogs. They can be used to persist data generated by our application, letting users choose the name and location of the new file.
Saving data into a file
Getting ready
We will use the Save file dialog to write the contents of a Text widget into a plain text file:
How to do it...
To open a dialog to save a file, we call the asksaveasfile function from the tkinter.filedialog module. It internally creates a file object with the 'w' mode for writing, or...