Making a panel with a background in wxPython

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)
 


WordPress database error: [Can't open file: 'wp_comments.MYD'. (errno: 145)]
SELECT * FROM wp_comments WHERE comment_post_ID = '202' AND comment_approved = '1' ORDER BY comment_date

No comments have been added to this post yet.

Leave a comment




Your e-mail address is never displayed. If you run into issues with SpamKarma blocking you, email me at $patrick->5etdemi(com)


RSS feed for comments on this post | TrackBack URI