Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63159 > unrolled thread

Update image in same window with, say, PIL

Started byJohn O'Hagan <research@johnohagan.com>
First post2014-01-05 12:40 +1100
Last post2014-01-05 12:40 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Update image in same window with, say, PIL John O'Hagan <research@johnohagan.com> - 2014-01-05 12:40 +1100

#63159 — Update image in same window with, say, PIL

FromJohn O'Hagan <research@johnohagan.com>
Date2014-01-05 12:40 +1100
SubjectUpdate image in same window with, say, PIL
Message-ID<mailman.4923.1388886064.18130.python-list@python.org>
I'm using something like the following to display an image and refresh
it in the same window each time the image file is updated:

import cv

def display(filename):
    """Display scores as they are created"""
    cv.NamedWindow(filename)
    while 1:
        ... #wait for signal that filename has been updated, 
            #or to break
        image = cv.LoadImage(filename)
        cv.ShowImage(filename, image)
        cv.WaitKey(1000)


I would like to do the same thing using PIL, for two reasons. First,
the main project is written in Python 3, but cv is only available in
Python 2, so I have to launch the above as a separate process and do
IPC with it, which is annoying; whereas PIL has recently come into
Python 3. Second, PIL seems like a more appropriate tool. CV is a
sophisticated computer-vision project which I happen to be more
familiar with, but I'm using it just to display an image, so I feel as
if I'm using the Mars Explorer to vacuum my apartment. 

I have found a couple of StackOverflow and ActiveState recipes to do
this but they all seem to involve great globs of windowing code
involving Tkinter or Qt, which I know nothing about. CV does seem to
magically manage the windowing. Can I do this equally simply with PIL,
or perhaps something else in Python 3?

Thanks,

--

John

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web