CodeMouse92
CodeMouse92

Reputation: 6898

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.

Upvotes: 2

Views: 3352

Answers (2)

Daniel H
Daniel H

Reputation: 399

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

Upvotes: 2

Mike Driscoll
Mike Driscoll

Reputation: 33071

Why would you have the image over the controls. I would put the controls to the side, on top or under the image. There have been several threads on pngs and transparency on the wxPython list lately: https://groups.google.com/forum/#!topic/wxpython-users/ANZGyF0kkZ0

or https://groups.google.com/forum/#!topic/wxpython-users/_X2zhlTj_Fg

Maybe one of those will help you too.

Upvotes: 0

Related Questions