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

时间:2021-11-26 07:12:41

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.

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

3 个解决方案

#1


2  

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

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

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

这是您必须为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

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

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

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.

你可以在wxPython文档和演示中找到一个利用这些类的工作示例,它叫做Grid_MegaExample。

#2


1  

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/

如果你不得不求助于编写自己的,我使用Python Imaging Library来创建缩略图的效果很好。 http://www.pythonware.com/products/pil/

#3


1  

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

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

#1


2  

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

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

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

这是您必须为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

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

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

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.

你可以在wxPython文档和演示中找到一个利用这些类的工作示例,它叫做Grid_MegaExample。

#2


1  

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/

如果你不得不求助于编写自己的,我使用Python Imaging Library来创建缩略图的效果很好。 http://www.pythonware.com/products/pil/

#3


1  

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

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