Tkinter with PIL crashing on large images - help
Joel Gould
joelg at alum.mit.edu
Mon Mar 12 07:42:37 EST 2001
Is this expected behavior? If I load a 3.3 megapixel JPG file into a
PIL (Python Image Library) PhotoImage object and then draw that on a
Tkinter.Canvas object, Python crashes with an access violation (under
WIndows 98).
I have attached the code that fails. You can ge a suitable image from
this link:
http://www.gouldhome.com/Travel/StThomas00/images/001229_1106_charlotteAmalie3.jpg
I have tried this using the latest py20 distribution (Python 2.0, PIL
1.1.1, etc.) from Secret Labs. I also tried it using the PythonWorks
Testdrive 1.1 (which uses Python 1.5.2) also from Secret Labs.
I am using Windows 98 SE on a Pentium III with 256MB of RAM.
Can anyone tell me why this is failing?
P.S. I know the image is very big and I can make it smaller before
displaying it. I just do not think it should GPF in this case.
Joel Gould
joelg at alum.mit.edu
----- snip ----
import Tkinter
import Image
import ImageTk
class MainDialog:
def __init__(self, parent):
self.canvas = Tkinter.Canvas(parent,width=700,height=500)
self.canvas.pack()
self.image = Image.open("001229_1106_charlotteAmalie3.jpg")
self.tkim = ImageTk.PhotoImage(self.image)
self.item = self.canvas.create_image(
0,0,image=self.tkim,anchor='nw')
if __name__ == '__main__':
root = Tkinter.Tk()
dialog = MainDialog(root)
root.mainloop()
More information about the Python-list
mailing list