[Tutor] Displaying .jpg in Tkinter (Python 3.1)

Alan Gauld alan.gauld at btinternet.com
Mon Aug 31 14:46:47 CEST 2009


"Dirk Wangsadirdja" <dirk at pensiun.com> wrote

> is there anyway to display a .jpg (or other type) images in Tkinter with 
> Python 3.1?

You can display a limited set of image types, including GIF and
JPG in Tkinter without PIL. Several Widgets take an image including
the Canvas and Text widgets. I think a label can be an image too,
but am not certain.

The trick is to crate an PhotoImage object  from your file and insert that
into the widget. To change the widget you modify the image object
not the widget.

See here for more info:

http://effbot.org/tkinterbook/photoimage.htm


HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/ 




More information about the Tutor mailing list