introduction to gui programming self statusbar after(timeoutself clearstatusbarthis method sets the status bar label' textand if there is timeout ( fivesecond timeout is the default)the method sets up single shot timer to clear the status bar after the timeout period def fileopen(self*ignore)if not self okaytocontinue()return dir (os path dirname(self filenameif self filename is not none else "filename tkinter filedialog askopenfilenametitle="bookmarks open file"initialdir=dirfiletypes=[("bookmarks files""bmf")]defaultextension=bmf"parent=self parentif filenameself loadfile(filenamethis method starts off the same as mainwindow filenew(to give the user the chance to save any unsaved changes or to cancel the file open action if the user chooses to continue we want to give them sensible starting directoryso we use the directory of the current file if there is oneand the current working directory otherwise the filetypes argument is list of (descriptionwildcard -tuples that the file dialog should show if the user chose filenamewe set the current filename to the one they chose and call the loadfile(method to do the actual file reading separating out the loadfile(method is common practice to make it easier to load file without having to prompt the user for examplesome programs load the last used file at start-upand some programs have recently used files listed in menu so that when the user chooses one the loadfile(method is called directly with the menu option' associated filename def loadfile(selffilename)self filename filename self listbox delete( tkinter endself dirty false trywith open(self filename"rb"as fhself data pickle load(fhfor name in sorted(self datakey=str lower)self listbox insert(tkinter endnameself setstatusbar("loaded { bookmarks from { }formatself listbox size()self filename)self parent title("bookmarks { }formatos path basename(self filename))