[Pythonmac-SIG] PIL related crash?

Jerry LeVan jerry.levan at eku.edu
Sat Jun 10 21:00:49 CEST 2006


Hi, I am trying my hand at trying to build a simple image
viewer for embedding into a larger application.

The following code will display images ok on my linux
box running python 2.4.2 and ActiveState Tcl/Tk 8.4.13

The same code crashes before the interface comes up on
my Mac OSX 10.4.6 Aqua TclTk Batteries included 8.4.10
and python 2.4.3, it looks like it is dying deep in
the imaging code.

Is this a know problem?

Any suggestions?

Jerry

*****************
#!/usr/bin/env python
from Tkinter import *
import Image, ImageTk

def build_scrolled_canvas(parent):

          canvas=Canvas(parent)

          sy = Scrollbar(parent,
                                         command=canvas.yview)
          sx = Scrollbar(parent, orient=HORIZONTAL,
                                         command= canvas.xview)
          canvas.configure(yscrollcommand=sy.set,xscrollcommand=sx.set)
          canvas.grid(row=0,column=0,sticky=NSEW)
          sy.grid(row=0,column=1,stick=N+S)
          sx.grid(row=1,column=0,sticky=E+W)
          parent.columnconfigure(0,weight=1)
          parent.rowconfigure(0,weight=1)
          return canvas
#
if __name__ == '__main__':

         theWin = Toplevel()
         theFrame = Frame(theWin)
         theCanvas = build_scrolled_canvas(theFrame)
         theButton= Button(theWin,text="exit",command=theWin.destroy)
         theFrame.pack(side=TOP, expand=TRUE, fill=BOTH)
         theButton.pack(side=TOP)
         im = Image.open(sys.argv[1])
         (width,height) = im.size
         tkim = ImageTk.PhotoImage(im)
         theCanvas.create_image(0,0,image=tkim,anchor=NW)
         theCanvas['scrollregion'] = (0,0,width,height)
         mainloop()
**********************


More information about the Pythonmac-SIG mailing list