Tkinter image problems
Chris
chris at localhost.localdomain
Mon May 27 02:18:54 EDT 2002
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