Efficient Image Thumbnail Control for Python?

浪尽此生 提交于 2019-12-21 05:42:09

问题


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.


回答1:


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.




回答2:


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/




回答3:


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



来源:https://stackoverflow.com/questions/215052/efficient-image-thumbnail-control-for-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!