Images (.bmp,.jpg,gif) in Tkinter windows (Tk newbie)

effbot at pythonware.com effbot at pythonware.com
Mon Mar 27 13:16:17 EST 2000


Tim Ottinger wrote:
> I'm in Win32. I need an example (that works) of loading a graphical
> image using Tkinter and python. Looking at the image and bitmap
> options hasn't helped me, because I'm reading win32 .bmp files, not
> xbm files. I'd like to read and display gifs, jpgs, and the like as
> part of my Tkinter dialogs.

native Tkinter supports GIF and PPM files (use the PhotoImage
class to load them).

   image = PhotoImage(file="myfile.gif")
   widget.config(image=image)
   widget.image = image # make sure to hang on to the image

to handle more formats, use PIL:

    http://www.pythonware.com/products/pil/

information on how to use the binary distribution of PIL
with python.org's standard distribution:

    http://www.deja.com/=dnc/getdoc.xp?AN=596580430
    http://www.pythonware.com/downloads.htm

</F>


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list