in our earlier image exampleswe attached widgets to buttons and canvasesbut the standard tkinter toolkit allows images to be added to variety of widget typesincluding simple labelstextand menu entries example - for instanceuses unadorned tkinter to display single image by attaching it to labelin the main application window the example assumes that images are stored in an images subdirectoryand it allows the image filename to be passed in as command-line argument (it defaults to spam gif if no argument is passedit also joins file and directory names more portably with os path joinand it prints the image' height and width in pixels to the standard output streamjust to give extra information example - pp \gui\pil\viewer-tk py ""show one image with standard tkinter photo objectas is this handles gif filesbut not jpeg imagesimage filename listed in command lineor defaultuse canvas instead of label for scrollingetc ""import ossys from tkinter import imgdir 'imagesimgfile 'london- gifif len(sys argv imgfile sys argv[ imgpath os path join(imgdirimgfilewin tk(win title(imgfileimgobj photoimage(file=imgpathlabel(winimage=imgobjpack(print(imgobj width()imgobj height()win mainloop(use standard tkinter photo object gif worksbut jpeg requires pil cmdline argument givendisplay photo on label show size in pixels before destroyed figure - captures this script' display on windows showing the default gif image file run this from the system console with filename as command-line argument to view other files in the images subdirectory ( python viewer_tk py filename gifviewing and processing images with pil