import wx
from PIL import Image def ConvertToWxImage():
pilImage = Image.open('1.png')
image = wx.EmptyImage(pilImage.size[0], pilImage.size[1])
image.SetData(pilImage.convert("RGB").tostring())
image.SetAlphaData(pilImage.convert("RGBA").tostring()[3::4]) bitmap = wx.BitmapFromImage(image)
return bitmap
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title = "Test convert ")
sizer = wx.BoxSizer(wx.HORIZONTAL)
bitmap = ConvertToWxImage()
bimCtr = wx.StaticBitmap(self, -1, bitmap)
sizer.Add(bimCtr)
self.SetSizerAndFit(sizer) app = wx.PySimpleApp()
frm = MyFrame()
frm.Show()
app.MainLoop()