From 6240e979c77938365c8dbd11e821a3976cb95201 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 16 Sep 2018 13:03:32 -0700 Subject: [PATCH] closes #286 - 2.7 / 3.0 wx bitmap creation compatibility --- gooey/gui/imageutil.py | 4 ++-- gooey/gui/three_to_four.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gooey/gui/imageutil.py b/gooey/gui/imageutil.py index 57ec515..7d11219 100644 --- a/gooey/gui/imageutil.py +++ b/gooey/gui/imageutil.py @@ -6,7 +6,7 @@ import six from PIL import Image import wx -from gooey.gui.three_to_four import imageFromBitmap, bitmapFromImage +from gooey.gui.three_to_four import bitmapFromBufferRGBA @@ -25,7 +25,7 @@ def wrapBitmap(im, parent): except AttributeError: rgba = im.convert('RGBA').tostring() - bitmapData = wx.Bitmap.FromBufferRGBA(im.size[0], im.size[1], rgba) + bitmapData = bitmapFromBufferRGBA(im, rgba) return wx.StaticBitmap(parent, bitmap=bitmapData) diff --git a/gooey/gui/three_to_four.py b/gooey/gui/three_to_four.py index 33dbfe2..43969b9 100644 --- a/gooey/gui/three_to_four.py +++ b/gooey/gui/three_to_four.py @@ -43,5 +43,9 @@ def bitmapFromImage(image): return wx.BitmapFromImage(image) - +def bitmapFromBufferRGBA(im, rgba): + if isLatestVersion: + return wx.Bitmap.FromBufferRGBA(im.size[0], im.size[1], rgba) + else: + return wx.BitmapFromBufferRGBA(im.size[0], im.size[1], rgba)