0

我正在尝试在可滚动窗口中显示一个非常大的地图。这个想法是你有一个方形瓷砖网格,每个瓷砖都有一个图像,你可以滚动查看它们。每个图块也有一些数字信息(我可以用 wx.StaticText 绘制它),您可以单击并右键单击图块以执行某些操作。

我在这方面的第一关是对每个图块使用 wx.Panel,对地图使用 wx.ScrolledWindow。但是,wx.ScrolledWindow 似乎在处理大量图块时性能很差(以大约 4fps 的速度滚动)。

我的下一个尝试是使用享元模式,正好有 9 个大面板,每个面板使用 wx.dc 渲染大约 100 个图块。当用户向一个方向滚动并且面板移出屏幕时,我将它们添加到死池并从死池重新配置新面板。但是,这似乎也不是特别好,因为每当重新定位面板时都会出现明显的闪烁。此外,似乎 wx.ScrolledWindow 内的面板是panel.SetPosition(...)根据当前滚动位置而不是虚拟空间的原点定位(例如)的,这使得难以避免竞争条件,因为滚动位置可能会在面板运行时发生变化仍在重新配置。

在 wxPython 中渲染非常大的滚动内容的推荐模式是什么?我熟悉在我的原生 WM 中实现这一点的方法,并且我已经看到在 wxWidgets 中实现了相当大的滚动区域。但是对于 wxPython 的大型滚动内容,似乎没有任何示例。

4

1 回答 1

0

Apparently the better way to scroll large content is with wx.lib.floatcanvas. There's a reasonable demo on GitHub. It's not quite native speed, but it's usable even on large graph sizes.

I haven't figured out how to do the 2D multitouch panning that the native scroller (on Mac) supports, as it doesn't seem to show up in the MouseWheel events. That could be a drawback if it's important to somebody's usecase, but it's not the end of the world for my project.

于 2013-05-04T07:57:06.870 回答