Browse Source

Compatibility with legacy versions of Pillow

Old versions of Pillow:Image don't support .tobytes(), so we use .tostring() instead.
pull/308/head
saddy001 6 years ago
committed by Chris
parent
commit
109f4972b2
1 changed files with 6 additions and 2 deletions
  1. 8
      gooey/gui/imageutil.py

8
gooey/gui/imageutil.py

@ -20,9 +20,13 @@ def resizeImage(im, targetHeight):
def wrapBitmap(im, parent):
bitmapData = wx.Bitmap.FromBufferRGBA(im.size[0], im.size[1], im.convert('RGBA').tobytes())
return wx.StaticBitmap(parent, bitmap=bitmapData)
try:
rgba = im.convert('RGBA').tobytes()
except AttributeError:
rgba = im.convert('RGBA').tostring()
bitmapData = wx.Bitmap.FromBufferRGBA(im.size[0], im.size[1], rgba)
return wx.StaticBitmap(parent, bitmap=bitmapData)
if __name__ == '__main__':

Loading…
Cancel
Save