self toolphotoobjs [for file in photosimg photoimage(file=imgdir filebtn button(toolbarimage=imgcommand=self greetingbtn config(bd= relief=ridgebtn config(width=size[ ]height=size[ ]btn pack(side=leftself toolphotoobjs append(imgkeep reference button(toolbartext='quit'command=self quitpack(side=rightfill=yfigure - menudemo images in the toolbar with pil when runthis alternative uses gif imagesand renders the window grabbed in figure - depending on your user' preferencesyou might want to resize the gif images used here for this role with other toolswe only get part of unresized photos in the fixed-width buttonswhich may or may not be enough as isthis is something of first cut solution to toolbar image buttons there are many ways to configure such image buttons since we're going to see pil in action again later in this when we explore canvasesthoughwe'll leave further extensions in the suggested exercise column automating menu construction menus are powerful tkinter interface device if you're like methoughthe examples in this section probably seem like lot of work menu construction can be both code intensive and error prone if done by calling tkinter methods directly better approach might automatically build and link up menus from higher-level description of their contents in factin we'll meet tool called guimixin that automates the menu construction processgiven data structure that contains all menus desired as menus