[Tutor] Displaying picture and Text

Tim Golden mail at timgolden.me.uk
Thu Nov 4 10:00:51 CET 2010


On 04/11/2010 04:24, patty at cruzio.com wrote:
> Hi - I am running Python 2.6.6 on my HP netbook with Windows 7. The
> default picture viewer is set to HP Photo Viewer.  I am working on a part
> of my python program where a picture is supposed to display with a few
> lines of text below it.  Ideally, I would like this to stay on the screen
> for  a short  period of time (2 minutes?) but I am using raw_input() for
> now.
>
> I imported the Image library and when I run the program below, it brings
> up a window (stdout or python?) with cursor flashing for a few seconds and
> then the HP Photo Viewer comes up with the picture, I close this window
> and then my text comes up in a python window.

The Image.show function in the PIL is simply a convenience for doing
a quick-and-dirty "What does this image look like?". It hands off to
the default image viewer -- as you discovered. It's not intended for
use in a production program which needs to control image size, placement
etc.

There probably *are* image viewers which you could control from the command
line to display what you want, but if you're going to need a solution
involving text and images, just use one of the existing GUI toolkits:
wxPython, PyQt or others (just search for "Python GUI") which let you
display text, images etc. with complete control.

TJG


More information about the Tutor mailing list