wxPython 将多个图像添加到面板问题 [英] wxPython Add multiple images to a panel issue

查看:40
本文介绍了wxPython 将多个图像添加到面板问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以单独的方法将位图添加到 GridSizer 中:

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

我的问题是,当将 StaticBitmap 添加到 sizer 时,它会创建加载效果并快速在父窗口中一个接一个地显示图像.之后,它们被加载到 sizer 中.

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.

有没有办法简单地将多个图像添加到面板,但避免静态位图?这种加载效果会导致执行过程中出现很大的延迟,因此无法选择静态 bmp.

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.

我也看过 wx.grid.Grid,但这似乎使事情更加复杂.

I have also looked at wx.grid.Grid, but this seems to complicate things even more.

谢谢!

推荐答案

我们在这里讨论了多少张图片?保存这些图像的文件有多大?如果您有很多大图像,您几乎无能为力,因为系统需要时间来加载位图并将它们排列在网格中.

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.

你看过 wx.lib.agw 中的 ThumbnailCtrl 吗?它可能会为您提供有关如何加快加载图像和显示图像的一些指示.

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.

最后,如果您有很多(非常多)图像,请不要使用 wx.StaticBitmap:尤其是在 Windows 上,操作系统很容易耗尽 GDI 对象并导致系统崩溃.

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.

安德里亚.

这篇关于wxPython 将多个图像添加到面板问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆