introduction to gui programming elseicon "@path "interest xbmapplication iconbitmap(iconapplication title("interest"window mainwindow(applicationapplication protocol("wm_delete_window"window quitapplication mainloop(after defining the class for the main (and in this case onlywindowwe have the code that starts the program running we begin by creating an object to represent the application as whole to give the program an icon on windows we use an ico file and pass the name of the file (with its full pathto the iconbitmap(method but for unix platforms we must provide bitmap ( monochrome imagetk has several built-in bitmapsso to distinguish one that comes from the file system we must precede its name with an symbol next we give the application title (which will appear in the title bar)and then we create an instance of our mainwindow class giving the application object as its parent at the end we call the protocol(method to say what should happen if the user clicks the close button--we have said that the mainwindow quit(method should be calledand finally we start the event loop--it is only when we reach this point that the window is displayed and is able to respond to user interactions main-window-style programs ||although dialog-style programs are often sufficient for simple tasksas the range of functionality program offers grows it often makes sense to create complete main-window-style application with menus and toolbars such applications are usually easier to extend than dialog-style programs since we can add extra menus or menu options and toolbar buttons without affecting the main window' layout in this section we will review the bookmarks-tk pyw program shown in figure the program maintains set of bookmarks as pairs of (nameurlstrings and has facilities for the user to addeditand remove bookmarksand to open their web browser at particular bookmarked web page the program has two windowsthe main window with the menu bartoolbarlist of bookmarksand status barand dialog window for adding or editing bookmarks creating main window |the main window is similar to dialog in that it has widgets that must be created and laid out and in addition we must add the menu barmenustoolbarand status baras well as methods to perform the actions the user requests