wxPython: images from URLs
Jonathan Daugherty
cygnus at cprogrammer.org
Wed Jan 28 11:42:02 EST 2004
# self._imgstream = urllib2.urlopen(url).read()
# stream=cStringIO.StringIO(self._imgstream)
#
# try:
# img=wxImageFromStream(stream)
# except:
# pass
I have tried this and it appears to work, but once I have
the image (from wxImageFromStream), I use it as follows:
try:
bm = wxBitmap(img)
self.bitmap.setBitmap(bm)
except Exception, e:
print e
And the exception (raised by wxBitmap(img)) is:
String or Unicode type required
(The exception is a TypeError exception.)
Any ideas? No exceptions are raised by the block that
creates the image from the data stream. The image is
a JPG image, and I pass wxBITMAP_TYPE_JPEG to
wxImageFromStream. I have also tried omitting it as
well.
--
Jonathan Daugherty
http://www.cprogrammer.org
"It's a book about a Spanish guy called Manual, you should read it."
-- Dilbert
More information about the Python-list
mailing list