wx.Image: Couldn't add an image to the image list.

Kartic kartic.krishnamurthy at gmail.com
Wed Jan 26 16:55:52 EST 2005


Laszlo,

If you are using PIL just for scaling, you can do away with PIL. Even
if you do other things with PIL, you can use the Rescale method of the
wx.Image instance to resize. Here is the code (adapted from the Demo):

data = open('C:/TEMP/test.bmp'), "rb").read()
stream = cStringIO.StringIO(data)
img = wx.ImageFromStream( stream )
img.Rescale(32, 32) # Resize your image to 32x32
bmp = wx.BitmapFromImage( img ) # Convert Image to Bitmap
# Now display Bitmap in Panel
wx.StaticBitmap(self, -1, bmp, (bmp.GetWidth(), bmp.GetHeight()))
Try this and see if this works for you.

Thank you,
--Kartic




More information about the Python-list mailing list