Reputation: 3
I am trying a add around 1,500 bitmaps to a ScrolledWindow, inside a GridSizer. They are loaded successfully (but a bit slow).
My issue is: whenever I scroll a bit faster, the whole thing freezes for 8-10 seconds.
Here is the relevant code:
class EmojiDBTab(wx.ScrolledWindow):
def __init__(self, parent):
wx.ScrolledWindow.__init__(self, parent)
self.SetScrollbars(1, 10, 1, 10)
dbtab_sizer = wx.GridSizer(len(TEST_UNICODE_EMOJI) / 10 + 1, 10, 0, 0)
for unicode in TEST_UNICODE_EMOJI:
emoji_symbol = EmojiBitmap(wx.Bitmap(unicode_to_pngfilename(unicode)),
TEST_UNICODE_EMOJI[unicode])
dbtab_sizer.Add(wx.StaticBitmap(self, -1, emoji_symbol.bitmap))
self.SetSizer(dbtab_sizer)
Is there a way to avoid the big delay after scrolling?
Thanks!
Upvotes: 0
Views: 156
Reputation: 33101
There are a couple of options. You can load up the number of images that you can see onscreen and then load more when the user scrolls. This would probably work pretty well. If you don't want the user to see them loading, then load two pages worth and just load on the scroll event.
Another option to consider is to create thumbnails of the images in the folder and show those instead. That should load considerably faster and might resolve the freezing issue.
The other option that comes to mind is to use a different widget, like wx.lib.imagebrowser
, which is made for this sort of thing.
Upvotes: 1