Search code examples
wxpythonpngwxwidgets

Display a transparent .png in wxpython


I'm using Python 2.7. I need to display a .png image file in wxpython, such that the transparency is preserved, and you can still see the controls behind the transparent part of the image. This needs to work in Windows, Mac, AND Linux.


Solution

  • I just wanted to add how to draw a png with transparencies normally, for those who google and come across this (as I did) so they dont end up thinking its not possible because of the accepted answer (as I did)

    import wx
    
    dc = wx.PaintDC(self)
    self.pngimage = wx.Bitmap('image.png', wx.BITMAP_TYPE_PNG)
    dc.DrawBitMap(self.pngimage, x, y)
    

    this is what I do, and all the transparencies are displayed perfectly. I'm using wxpython 2.9.4.0