I have written some code for this in my PyWiew application
which allows one to open image urls directly.
Copying some relevant code from the application...
self._imgstream = urllib2.urlopen(url).read()
stream=cStringIO.StringIO(self._imgstream)
try:
img=wxImageFromStream(stream)
except:
pass
In short you do the following.
1. Use urllib or urllib2 to open the image data stream
2. Make a cStringIO string buffer from the data stream
3. Pass it to "wxImageFromStream()" method to get the
wxImage object.
4. Display the image directly or by converting to
a suitable format using PIL.
In my experience I found that wxWindows tend to
display an error message window when the image is displayed
directly as a wxImage though the image data is quite ok.
(Something like a corrupt stream dialog). So what I have
done in the application is, use PIL to convert the wxImage
to Windows BMP format and then display it. This seems
to work for all images.
HTH.
-Anand
Tim Roberts <
[email protected]> wrote in message