views:

129

answers:

1

I'm looking to add double buffering to a drawing function like this.

    dc = wx.PaintDC(self)
    gc = wx.GraphicsContext.Create(dc)
    #draw GraphicsPaths to the gc

I tried to first draw to a MemoryDC and then blit that back to the PaintDC:

    dc = wx.MemoryDC()
    dc.SelectObject(wx.NullBitmap)
    gc = wx.GraphicsContext.Create(dc)
    #draw GraphicsPaths to the gc
    dc2=wx.PaintDC(self)
    dc2.Blit(0,0,640,480,dc,0,0)

However, this gives me nothing but a blank screen. Am I misunderstanding how the MemoryDC is supposed to work?

+1  A: 

You need to create a bitmap, not use wx.NullBitmap.

bitmap = wx.EmptyBitmap(w, h)
dc = wx.MemoryDC(bitmap)
FogleBird