flickering in wxPython with bliting and memmoryDC

Tim Gahnström /Bladerman tim at bladerman.com
Wed Apr 16 03:36:25 EDT 2003


Hi
I have a wxPanel that flickers a whole lot, first I didn't give it much
consideration since I though the flickering was a common problem and would
stop as soon as I introduced a double buffer. But now, when I have tried
that, and it still flickers just as much I feel stuck.

I guess I have overlooked something and would much appreciate if someone
would have a quick look at my paint method (wich gets called everytime a
refresh is issued). Speed is not an issue, just the flickering .


def onPaintEvent(self, event):
#self.output is the wxPanel where I want my drawings
    dc = wxPaintDC(self.output)
    mdc = wxMemoryDC()
    x,y = self.output.GetSizeTuple()

#I read that these thre lines are needed
    bitmap = wxEmptyBitmap( x,y, -1 )
    mdc.SelectObject( bitmap )
    mdc.BeginDrawing()

#This loop draws my objects onto a dc
#In this case the memoryDC I would presume?
    for drawObj in self.contents:
        drawObj.draw(mdc)

#Also needed
    mdc.EndDrawing()

#Here I just blit the mdc-img over to the dc in one move
#How can it flicker then?
    dc.BeginDrawing()
    dc.Blit( 0,0,x,y, mdc, 0,0)
    dc.EndDrawing()


The panel is not large or anything and refreshes arent done at a particular
high speed, but it flickers everytime. Just like if the dc gets cleared
before the blitting but I can't se that I do that.

I have been looking at this for hours and would appreciate any pointer.

Thanks

Tim






More information about the Python-list mailing list