Computer Studies‎ > ‎Python‎ > ‎References‎ > ‎

Displaying Jpeg Images in Python

As I understand it, Python's resident Tkinter GUI library does not include a provision to display jpeg images. To get around this, Python Imaging Library (PIL) can be used, as shown below:

from Tkinter import *   
from PIL import Image, ImageTk  

root = Tk() 

image ="VenusTransit.jpg")  

photo = ImageTk.PhotoImage(image)   

Label(root, image=photo).pack()

Label(root, text="Venus Transit").pack()


The above program displays the following:

My thanks to Kevin McGrinder in my ICS4U class for researching this.