使用 wxpython 进行双缓冲

发布于 2024-07-14 11:27:05 字数 570 浏览 9 评论 0原文

我正在使用 wxpython 开发一个多平台应用程序,并且在面板上绘图时在 Windows 上遇到闪烁问题。 我曾经在鼠标移动事件期间在缓冲区(wx.Bitmap)上绘图,我的 OnPaint 方法仅由在线组成:

dc = wx.BufferedPaintDC(self, self.buffer)

相当标准,但我在 Windows 上仍然遇到闪烁问题,而在 Linux 上一切正常。

我在 __init__ 方法中调用 SetDoubleBuffered(True) 解决了我的问题。

奇怪的是,即使我不再使用 BufferedPaintDC,现在一切正常。 我更改了我的应用程序,以便所有绘图部分都在 OnPaint 方法中完成。 我不使用缓冲区,直接在 wx.PaintDC 上进行绘图,完全没有闪烁问题。

所以我的问题是:BufferedPaintDC 完全没用吗? 或者以某种方式被弃用? 我是《WxPython in Action》(2006 年)一书的所有者,它甚至没有提到 SetDoubleBuffered

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心如荒岛 2024-07-21 11:27:05

SetDoubleBuffered 实际上使您的面板自动使用缓冲 dc 的可能性很高,文档中没有提到这些类已被弃用(我宁愿认为如果是这种情况它们也会这样做)。

关于 wxPython in Action...2006 年已经是很久以前的事了...SetDoubleBuffered 方法可能当时还不存在,或者作者想展示底层是如何工作的。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文