introduction to gui programming from the first to the last--tkinter end is constant used to signify the last item in contexts where widget can contain multiple items then we clear the dirty flagfilenameand datasince the file is new and unchangedand we set the window title to reflect the fact that we have new but unsaved file the ignore variable holds sequence of zero or more positional arguments that we don' care about in the case of methods invoked as result of menu options choices or toolbar button presses there are no ignored argumentsbut if keyboard shortcut is used ( ctrl+ )then the invoking event is passedand since we don' care how the user invoked the actionwe ignore the event that requested it def okaytocontinue(self)if not self dirtyreturn true reply tkinter messagebox askyesnocancel"bookmarks unsaved changes""save unsaved changes?"parent=self parentif reply is nonereturn false if replyreturn self filesave(return true if the user wants to perform an action that will clear the list box (creating or opening new filefor example)we must give them chance to save any unsaved changes if the file isn' dirty there are no changes to saveso we return true right away otherwisewe pop up standard message box with yesnoand cancel buttons if the user cancels the reply is nonewe take this to mean that they don' want to continue the action they started and don' want to saveso we just return false if the user says yesreply is trueso we give them the chance to save and return true if they saved and false otherwise and if the user says noreply is falsetelling us not to savebut we still return true because they want to continue the action they startedabandoning their unsaved changes tk' standard dialogs are not imported by import tkinterso in addition to that import we must do import tkinter messageboxand for the following methodimport tkinter filedialog on windows and mac os the standard native dialogs are usedwhereas on other platforms tk-specific dialogs are used we always give the parent to standard dialogs since this ensures that they are automatically centered over the parent window when they pop up all the standard dialogs are modalwhich means that once one pops upit is the only window in the program that the user can interact withso they must close it (by clicking okopencancelor similar buttonbefore they can interact with the rest of the program modal dialogs are easiest for programmers to