self pix config(image=photoif __name__ ='__main__'buttonpicsdemo(mainloop(this version works the same way as the originalbut it can now be attached to any other gui where you would like to include such an unreasonably silly button viewing and processing images with pil as mentioned earlierpython tkinter scripts show images by associating independently created image objects with real widget objects at this writingtkinter guis can display photo image files in gifppmand pgm formats by creating photoimage objectas well as -style bitmap files (usually suffixed with an xbm extensionby creating bitmapimage object this set of supported file formats is limited by the underlying tk librarynot by tkinter itselfand may expand in the future (it has not in many yearsbut if you want to display files in other formats today ( the popular jpeg format)you can either convert your files to one of the supported formats with an image-processing program or install the pil python extension package mentioned at the start of pilthe python imaging libraryis an open source system that supports nearly graphics file formats (including gifjpegtiffpngand bmpin addition to allowing your scripts to display much wider variety of image types than standard tkinterpil also provides tools for image processingincluding geometric transformsthumbnail creationformat conversionsand much more pil basics to use its toolsyou must first fetch and install the pil packagesee thonware com (or search for "pilon the webthensimply use special photoimage and bitmapimage objects imported from the pil imagetk module to open files in other graphic formats these are compatible replacements for the standard tkinter classes of the same nameand they may be used anywhere tkinter expects photoimage or bitmapimage object ( in labelbuttoncanvastextand menu object configurationsthat isreplace standard tkinter code such as thisfrom tkinter import imgobj photoimage(file=imgdir "spam gif"button(image=imgobjpack(viewing and processing images with pil