Double buffering with wxpython

此生再无相见时 提交于 2019-12-21 04:16:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!