Draw wx.StaticBitmap, which is inside a sizer, with wx.PaintDC (wx.EVT_PAINT)

Hi, Neo

Your code is painting on the client area of the frame, but there are also StaticBitmap’s that repaint their client area, which results in a glitchy look.

This seems to be related to your previous post. I think the easiest way is to set bitmaps on your transparent buttons <wx.lib.platebtn> by just adding,

    self.btn.SetBitmap(your_png)

As far as I can think of, two other ways to achieve your goals:

  1. Draw a bitmap on the base bitmap to make one bitmap image.
    Suppose A and B are fore and back bitmap images,
    dc = wx.MemoryDC(B)
    dc.DrawBitmap(A, x, y, useMask=True)
    del dc
    self.base = wx.StaticBitmap(self, bitmap=B)

EDIT In this case, you don’t need to handle EVT_PAINT

  1. If you are planning to implement pan (zoom and drag), wx.lib.floatcanvas.FloatCanvas could be a good alternative to wx.StaticBitmap.
    Please see my previous posts: this and this
1 Like