work with since the user cannot change the program' state behind the dialog' backand because they block until they are closed the blocking means that when we create or invoke modal dialog the statement that follows will be executed only when the dialog is closed def filesave(self*ignore)if self filename is nonefilename tkinter filedialog asksaveasfilenametitle="bookmarks save file"initialdir="filetypes=[("bookmarks files""bmf")]defaultextension=bmf"parent=self parentif not filenamereturn false self filename filename if not self filename endswith(bmf")self filename +bmftrywith open(self filename"wb"as fhpickle dump(self datafhpickle highest_protocolself dirty false self setstatusbar("saved { items to { }formatlen(self data)self filename)self parent title("bookmarks { }formatos path basename(self filename))except (environmenterrorpickle pickleerroras errtkinter messagebox showwarning("bookmarks error""failed to save { }:\ { }formatself filenameerr)parent=self parentreturn true if there is no current file we must ask the user to choose filename if they cancel we return false to indicate that the entire operation should be cancelled otherwisewe make sure that the given filename has the right extension using the existing or new filename we save the pickled self data dictionary into the file after saving the bookmarks we clear the dirty flag since there are now no unsaved changesand put message on the status bar (which will time out as we will see in moment)and we update the window' title bar to include the filename (without the pathif we could not save the filewe pop up warning message box (which will automatically have an ok buttonto inform the user def setstatusbar(selftexttimeout= )self statusbar["text"text if timeout