[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: Problem with Tkinter.PhotoImage

Fredrik Lundh

1/10/2008 7:36:00 PM

Cédric Lucantis wrote:

> I can only load gif images with Tkinter.PhotoImage and none with BitmapImage.
> I tried png, jpg, bmp and xpm and always got this errors :
>
>>>> img = Tkinter.PhotoImage(file='/home/omer/fgfs/fgsync/map.xpm')
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 3206, in __init__
> Image.__init__(self, 'photo', name, cnf, master, **kw)
> File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 3162, in __init__
> self.tk.call(('image', 'create', imgtype, name,) + options)
> _tkinter.TclError: couldn't recognize data in image
> file "/home/omer/fgfs/fgsync/map.xpm"

to add to Kevin's reply, you seem to have a properly configured PIL on
your machine:

> python-imaging
> python-imaging-tk

which means that you could try replacing Tkinter.PhotoImage with

from PIL import ImageTk

img = ImageTk.PhotoImage(file='/home/omer/fgfs/fgsync/map.xpm')

(PIL's XPM support isn't 100% perfect though; if it looks like crap, try
using PNG or GIF or some other not quite as silly format...)

</F>