Posted on Thursday 8 June 2006
I struggled trying to achieve layering effects in wxPython (which doesn't have a depth manager), in particular trying to get a background under my controls. As it turned out, you have to paint the background yourself, which may sound a bit over the top, but works really well once you get the hang of it. Here's some sample code:
class BackgroundPanel(wx.Panel):
def __init__(self, parent, background):
wx.Panel.__init__(self, parent, -1)
img = wx.Image(background, wx.BITMAP_TYPE_ANY)
self.buffer = wx.BitmapFromImage(img)
dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
self.Bind(wx.EVT_PAINT, self.OnPaint)
def OnPaint(self, evt):
dc = wx.BufferedPaintDC(self, self.buffer)


