Does PIL work with Tk 8.5?

Kevin Walzer kw at codebykevin.com
Mon Jan 7 17:20:51 EST 2008


I'm using a build of Python 2.5.1 on OS X 10.5.1 that links to Tk 8.5. 
Trying to test PIL with this new build, Python barfs when trying to 
display an image in a Tkinter Label. Here is my sample code:

---
from Tkinter import *
import Image, ImageTk

root = Tk()

im = Image.open('/Users/kevin/Desktop/to.jpg')
newim = im.resize((16, 16))

labelimage = ImageTk.PhotoImage(newim)

w = Label(root,  text="My Test Icon", image=labelimage, width=100)
w.image=labelimage
w.pack()

mainloop()
--

Here's the error message:

Macintosh:Desktop kevin$ python iconlabel.py
alloc: invalid block: 0x5c32b4: 5d 0 0

Abort trap
Macintosh:Desktop kevin$


The build of PIL was made against the pre-compiled binary of Python for 
OS X (from python.org) that links to Tk 8.4.

Since Python itself is the same version number (2.5.1), the only thing I 
can find to account for the crash is the different version of Tk--could 
this be making a difference, or am I doing something wrong?

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com



More information about the Python-list mailing list