wxPython 中可点击图像网格的有效方法?
在 wxPython 中显示大约 1000 个可点击图像的网格的最有效方法是什么?
目前我正在使用充满 StaticBitmap
对象的 GridSizer
。但对于 500 多张图像来说,速度相当慢。
另一件事是,我的左侧有一个类别列表框。也就是对图像进行过滤。类别将是“全部”、“类别 1”、“类别 2”等。当我单击“全部”时,必须显示所有图像。
我目前是如何做到这一点的:
- 垂直
BoxSizer
将包含 nGridSizer
对象,每个对象一个 类别。我添加StaticBitmap
对象到多个 GridSizer 取决于它的类别 属于. - 然后我只显示 GridSizer 取决于哪个类别 。
对于超过 300 张图像,此方法也非常慢 那么,如何才能有效地达到同样的效果呢?
。
Which is the most efficient method to display a grid of about 1000 clickable images in wxPython ?
Currently i am using a GridSizer
filled with StaticBitmap
objects. But its quite slow for 500+ images.
One more thing is that, i have a listbox of categories on the left. That is to filter the images. Categories will be like "All", "Cat 1", "Cat 2" etc. When i click "All", all the image have to be displayed.
How i am doing this currently :
- A VERTICAL
BoxSizer
will contain nGridSizer
objects, one for each
category. I add theStaticBitmap
objects to multiple GridSizers
depending on the categories it
belongs to. - Then i display only that GridSizer
depending on which category is
selected
This method is also terribly slow for anything over 300 images. So, how do i achieve the same effect efficiently ?
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设屏幕上不会同时显示所有 1000 张图像,对吗?如果是这样,您应该能够加载所需的数字,并在用户滚动时根据需要加载下一组。我认为 wxPython 列表中的人通常使用 DC 在屏幕上传输图像,或者使用 FloatCanvas 小部件。我建议询问他们的列表,其中有许多在屏幕上绘制图像的专家:https://groups.google.com/forum/#!forum/wxpython-users
I'm assuming that not all 1000 images are onscreen at the same time, correct? If so, you should be able to just load up the number you need and when the user scrolls, load up the next set as needed. I think the people on the wxPython list usually used DCs to blit their images onscreen or they use the FloatCanvas widget. I would recommend asking over on their list where there are a number of experts on drawing images onscreen: https://groups.google.com/forum/#!forum/wxpython-users
我认为 ICON 风格的 ListCtrl 将是实现此目的的最佳方法。
如果您查看 wxPython 演示,wx.LC_ICON 样式的 UltimateListCtrl 示例就是您可以创建的一个很好的示例。
I would think a ListCtrl in ICON style would be the best way to do this.
If you look at the wxPython Demos, the UltimateListCtrl sample in the wx.LC_ICON style is a good example of what you could create.