[Image-SIG] im.show does not show, and Tkinter isn't displaying my jpg image
Frédéric Mantegazza
frederic.mantegazza at gbiloba.org
Sun Mar 16 10:15:07 CET 2008
On dimanche 16 mars 2008, Stanley Sokolow wrote:
> I'm stumped, and it seems it should be so simple. I've been building a
> GUI with Pmw and Tkinter, and I reached a point where I want to display
> a jpg image on a Label object. I've followed the rules and examples
> carefully, importing the right modules, creating, packing, etc., but no
> image. The code will display a text string in the label, but not an
> image. I get no error messages. So I tried a simple PIL test case:
>
> import Image
> im = Image.open("sampleImage.jpg")
> im.show()
>
> I'm running Python 2.5.1 on Windows Vista with PIL 1.1.6 installed
> (verified with Image.VERSION). I get no error messages. I should see
> the image in Windows Photo Gallery, but the gallery says only "There are
> no pictures or videos selected" when PIL runs it. Windows does display
> the sampleImage.jpg file when I click the file name in Windows Explorer,
> so it doesn't seem to be a bad photo file. It's in the same directory
> as the test program, so the path is correct.
>
> I tried adding a forced load:
> import Image
> im = Image.open("sampleImage.jpg")
> pix = im.load()
> im.show()
>
> But no different results. Still no image. So I added a "print im"
> statement, which confirms that an image object was created:
> <JpegImagePlugin.JpegImageFile instance at 0x014B3C10>
>
> What am I doing wrong? Can anyone suggest anything else to check?
According to the manual :
"im.show()
Displays an image. This method is mainly intended for debugging purposes.
On Unix platforms, this method saves the image to a temporary PPM file, and
calls the xv utility.
On Windows, it saves the image to a temporary BMP file, and uses the
standard BMP display utility to show it.
This method returns None."
So, be sure to have a default utility to show a BMP image, and also check
that the file is really save somewhere...
--
Frédéric
http://www.gbiloba.org
More information about the Image-SIG
mailing list