From: Filipe P. A. F. <oc...@gm...> - 2010-04-12 13:57:41
|
Thanks for point TKinter to me. However, I'm stuck again. I've tried two approaches, one is following what you suggested: """ Tkinter """ import Tkinter as tk root = tk.Tk() from PIL import Image, ImageTk image = ImageTk.PhotoImage(Image.open('map.png')) # load saved image #image = ImageTk.PhotoImage(im) # load image from StringIO tk.Label(root, image=image).pack() The other is to convert the PIL image to array and show with imshow() """ PIL to array """ from matplotlib.image import pil_to_array rgba = pil_to_array(Image.open('map.png')) # load saved image #rgba = pil_to_array(im) # load image from StringIO rgba = rgba.astype(np.float32)/255. imshow(rgba) Both work fine for a saved image. However, they return strange errors when I tried to apply them to the image from "StringIO", or even for a saved image in the same script used to generate them. I guess that something I import from matplotlib is causing a conflict here. Here are the error messages: """ Tkinter """ _tkinter.TclError: image "pyimage9" doesn't exist """ PIL to array """ terminate called after throwing an instance of 'char const*' I'm attaching the script. Aborted |