问题
I'm working on an multiplatform application with wxpython and I had flickering problems on windows, while drawing on a Panel. I used to draw on a buffer (wx.Bitmap) during mouse motions events and my OnPaint method was composed of just on line:
dc = wx.BufferedPaintDC(self, self.buffer)
Pretty standard but still I had flickering problems on Windows, while everything worked fine on Linux.
I solved my problem calling SetDoubleBuffered(True)
in the __init__
method.
The strange thing is that now everything works even if I don't use BufferedPaintDC anymore. I changed my application so that all the drawing part is done in the OnPaint method. I don't use a buffer and drawing is done directly on a wx.PaintDC with no flickering problems at all.
So my question is: is BufferedPaintDC totally useless? Or deprecated somehow? I'm owner of the book "WxPython in Action" (2006) and it doesn't even mention SetDoubleBuffered
回答1:
There is a high probability that the SetDoubleBuffered actually makes your panel use a buffered dc automatically, the documentation doesn't mention that those classes are deprecated (and I rather think they would if that were the case).
About wxPython in Action... 2006 was a long time ago... it is possible that the SetDoubleBuffered method didn't exist back then or that the author wanted to show how things work at the lower level.
来源:https://stackoverflow.com/questions/581085/double-buffering-with-wxpython