:\pp \gui\tourimgcanvas py ora-ppr-german gif and that' all there is to it in we'll see images show up again in the items of menuin the buttons of window' toolbarin other canvas examplesand in the image-friendly text widget in later we'll find them in an image slideshow (pyview)in paint program (pydraw)on clocks (pyclock)in generalized photo viewer (pyphoto)and so on it' easy to add graphics to guis in python/tkinter once you start using photos in earnestthoughyou're likely to run into two tricky bits that want to warn you about heresupported file types at presentthe standard tkinter photoimage widget supports only gifppmand pgm graphic file formatsand bitmapimage supports windows-style xbm bitmap files this may be expanded in future releasesand you can convert photos in other formats to these supported formats ahead of timeof course but as we'll see later in this it' easy to support additional image types with the pil open source extension toolkit and its photoimage replacement hold on to your imagesunlike all other tkinter widgetsan image is utterly lost if the corresponding python image object is garbage collected that means you must retain an explicit reference to image objects for as long as your program needs them ( assign them to long-lived variable nameobject attributeor data structure componentpython does not automatically keep reference to the imageeven if it is linked to other gui components for display moreoverimage destructor methods erase the image from memory we saw earlier that tkinter variables can behave oddly when reclaimedtoo (they may be unset)but the effect is much worse and more likely to happen with images this may change in future python releasesthough there are good reasons for not retaining big image files in memory indefinitelyfor nowthoughimages are "use it or lose itwidget fun with buttons and pictures tried to come up with an image demo for this section that was both fun and useful settled for the fun part example - displays button that changes its image at random each time it is pressed example - pp \gui\tour\buttonpics-func py from tkinter import from glob import glob import democheck import random gifdir /gifs/get base widget set filename expansion list attach checkbutton demo to me pick picture at random where to look for gif files images