问题
I am trying to add bitmaps into a GridSizer, in a separate method:
def populate_grid_with_emojis(self, category):
for i in range(len(self.emoji_categories[category])):
emoji_string = self.emoji_categories[category][i].lower()
if '_skin_tone' in UNICODE_EMOJI[STRING_UNICODE[emoji_string]]:
continue
init_emoji = wx.Image(unicode_to_filename(STRING_UNICODE[emoji_string], 32))
emoji = EmojiBitmap(wx.Bitmap(init_emoji),
UNICODE_EMOJI[STRING_UNICODE[emoji_string]])
static_bmp = wx.StaticBitmap()
static_bmp.Create(self, -1, wx.Bitmap(init_emoji))
self.emoji_bmps_sizer.Add(static_bmp)
self.added_emojis[UNICODE_EMOJI[STRING_UNICODE[emoji_string]]] = emoji
My issue is that when adding the StaticBitmap to the sizer, it creates a loading effect and quickly shows the images one after the other, in the parent window. After that they are loaded into the sizer.
Is there a way to simply add multiple images to a panel, but avoiding static bitmaps? That loading effect causes a big lag during the execution, so static bmps are not an option.
I have also looked at wx.grid.Grid, but this seems to complicate things even more.
Thanks!
回答1:
How many images are we talking about here? How big are the files holding those images? If you have many, large images there is pretty much nothing you can do as the system will need time to load the bitmaps and arrange them in a grid.
Have you looked at the ThumbnailCtrl in wx.lib.agw? It may give you some pointer on how to speed up loading images and displaying them.
Finally, if you have many (very many) images, don’t use wx.StaticBitmap: especially on Windows, the OS can easily run out of GDI objects and bring your system down.
Andrea.
来源:https://stackoverflow.com/questions/52950574/wxpython-add-multiple-images-to-a-panel-issue