Efficient method for a grid of clickable images in wxPython?
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. Tha开发者_Python百科t 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 ?
.
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
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.
精彩评论