Tkinter image problems

Geiger Ho s997659 at ee.cuhk.edu.hk
Mon May 27 03:04:32 EDT 2002


The PhotoImage class imported from Tkinter.py just supports GIF and
PPM/PGM formats. You need to go to go to
http://www.pythonware.com/products/pil/ to get the Python Imaging Library
to support the other formats.


On 26 May 2002, Chris wrote:

> Hi, I posted a few days ago about problems getting images to work in Tkinter
> 
> The Tkinter test routine runs fine, but when I try to load in images it 
> won't work
> 
> Here's how i'm loading a TIFF:
> from Tkinter import *
> 
> class GF_control:
>     def __init__(self):
>         # Initialize TK
>         self.root = Tk()
>         self.root.config(height=300, width=400)
> 
>         # Load image
>         p = PhotoImage()
>         p.config(file='bla.tif')
> 
>         # Make label
>         splash = Label(self.root)
>         splash.pack()
> 
>         self.root.mainloop()
> 
> if 1:
>     f = GF_control()
> 
> And here's the error I get:
> Traceback (most recent call last):
>   File "<stdin>", line 18, in ?
>   File "<stdin>", line 11, in __init__
>   File "/usr/lib/python2.1/lib-tk/Tkinter.py", line 2951, in configure
>     self.tk.call((self.name, 'config') + res)
> TclError: couldn't recognize data in image file "bla.tif"
> 
> Here's the error for the same, using a PNG instead:
> 
> Traceback (most recent call last):
>   File "<stdin>", line 18, in ?
>   File "<stdin>", line 11, in __init__
>   File "/usr/lib/python2.1/lib-tk/Tkinter.py", line 2951, in configure
>     self.tk.call((self.name, 'config') + res)
> TclError: couldn't recognize data in image file "bla.png"
> 
> And the error for a JPG:
> 
> Traceback (most recent call last):
>   File "<stdin>", line 18, in ?
>   File "<stdin>", line 11, in __init__
>   File "/usr/lib/python2.1/lib-tk/Tkinter.py", line 2951, in configure
>     self.tk.call((self.name, 'config') + res)
> TclError: couldn't recognize data in image file "bla.jpg"
> 
> All of the images load fine in GIMP
> 
> 




More information about the Python-list mailing list