introduction to gui programming has left it with some odd corners menu bars created like this do not need to be laid outtk will do that for us filemenu tkinter menu(menubarfor labelcommandshortcut_textshortcut in ("new "self filenew"ctrl+ """)("open "self fileopen"ctrl+ """)("save"self filesave"ctrl+ """)(nonenonenonenone)("quit"self filequit"ctrl+ """))if label is nonefilemenu add_separator(elsefilemenu add_command(label=labelunderline= command=commandaccelerator=shortcut_textself parent bind(shortcutcommandmenubar add_cascade(label="file"menu=filemenuunderline= each menu bar menu is created in the same way first we create tkinter menu object that is child of the menu barand then we add separators or commands to the menu (note that an accelerator in tk terminology is actually keyboard shortcutand that all the accelerator option sets is the text of the shortcutit does not actually set up key binding the underline indicates which character is underlinedin this case the first one of every menu optionand this letter becomes the menu option' keyboard accelerator in addition to adding menu option (called command)we also provide keyboard shortcut by binding key sequence to the same command as that invoked when the corresponding menu option is chosen at the end the menu is added to the menu bar using the add_cascade(method we have omitted the edit menu since it is structurally identical to the file menu' code frame tkinter frame(self parentself toolbar_images [toolbar tkinter frame(framefor imagecommand in ("images/filenew gif"self filenew)("images/fileopen gif"self fileopen)("images/filesave gif"self filesave)("images/editadd gif"self editadd)("images/editedit gif"self editedit)("images/editdelete gif"self editdelete)("images/editshowwebpage gif"self editshowwebpage))image os path join(os path dirname(__file__)imagetry