Python 的高效图像缩略图控制?

发布于 2024-07-07 03:56:45 字数 103 浏览 2 评论 0原文

对于 Python GUI 应用程序显示大量缩略图(例如 10000 个或更多)的最佳选择是什么? 出于性能原因,此类缩略图控件必须支持虚拟项目,即仅请求应用程序当前对用户可见的那些缩略图。

What is the best choice for a Python GUI application to display large number of thumbnails, e.g. 10000 or more? For performance reasons such thumbnail control must support virtual items, i.e. request application for those thumbnails only which are currently visible to user.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

若水微香 2024-07-14 03:56:45

wxPython 中,您可以使用 wxGrid 为此,因为它支持虚拟模式和自定义单元格渲染器。

这是您必须为 wxGrid“数据提供者”实现的最小接口:

class GridData(wx.grid.PyGridTableBase):
    def GetColLabelValue(self, col):
        pass

    def GetNumberRows(self):
        pass

    def GetNumberCols(self):
        pass

    def IsEmptyCell(self, row, col):
        pass

    def GetValue(self, row, col):
        pass

这是您必须为 wxGrid 单元格渲染器实现的最小接口:

class CellRenderer(wx.grid.PyGridCellRenderer):
    def Draw(self, grid, attr, dc, rect, row, col, isSelected):
        pass

您可以在 wxPython 文档和演示中找到使用这些类的工作示例,它称为 Grid_MegaExample。

In wxPython you can use wxGrid for this as it supports virtual mode and custom cell renderers.

This is the minimal interface you have to implement for a wxGrid "data provider":

class GridData(wx.grid.PyGridTableBase):
    def GetColLabelValue(self, col):
        pass

    def GetNumberRows(self):
        pass

    def GetNumberCols(self):
        pass

    def IsEmptyCell(self, row, col):
        pass

    def GetValue(self, row, col):
        pass

This is the minimal interface you have to implement for a wxGrid cell renderer:

class CellRenderer(wx.grid.PyGridCellRenderer):
    def Draw(self, grid, attr, dc, rect, row, col, isSelected):
        pass

You can find a working example that utilizes these classes in wxPython docs and demos, it's called Grid_MegaExample.

为人所爱 2024-07-14 03:56:45

如果您必须自己编写缩略图,我过去使用 Python 图像库创建缩略图已经取得了很好的结果。
http://www.pythonware.com/products/pil/

If you had to resort to writing your own, I've had good results using the Python Imaging Library to create thumbnails in the past.
http://www.pythonware.com/products/pil/

沙与沫 2024-07-14 03:56:45

只是为了完整性:有一个用wxPython编写的thumbnailCtrl,这可能是一个很好的起点。

Just for completeness: there is a thumbnailCtrl written in/for wxPython, which might be a good starting point.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文