The goal for this iteration is to complete the functioning of the File menu options of Open, Save, and Save As.
We regularly use the Open and Save dialogs. They are common across many programs. We know how these menu items behave. For instance, when you click on the Open menu, it opens up a dialog form that lets you traverse to the location of the file you want to open. When you select a particular file and click on Open, it opens up in your editor. Similarly, we have the Save dialog.
While we can implement these dialogs using standard Tkinter widgets, it turns out that they are so commonly used that a specific Tkinter module called tkFileDialog
has been included in the standard Python distribution. We will not try to reinvent the wheel and in the spirit of less coding, we will use the tkFileDialog
module to implement Open and Save functionality for our text editor as shown in the following screenshot: