如何(快速)使用PyQT4缩放300张图像?

Ble*_*der 5 python drag-and-drop thumbnails pyqt4

我正在(仍然)使用书籍装订应用程序,并且为了使其美观,我已经为你拖入的每个页面添加了一个缩略图.它工作正常,但唯一的问题是当我拖入一个整体书(即400张图片),它完全冻结,直到它完成.

这是我的简单删除代码:

  def fileDropped(self, file):
    f = str(file[-1])

    if os.path.splitext(f)[1][1:] != 'tif':
      reply = QtGui.QMessageBox.question(self, 'Message', 'All files must be TIF images. Would you like me to convert a copy of your file to the TIF format?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No)

      if reply == QtGui.QMessageBox.Yes:
        if not os.path.exists('./djvu_backup/'):  os.mkdir('./djvu_backup/')



        if f not in self.getChildren(self.ui.pageList):   # It's a custom method. It does what it looks like it does.
          icon = QtGui.QIcon(f)
          pixmap = icon.pixmap(72, 72)
          icon = QtGui.QIcon(pixmap)
          item = QtGui.QListWidgetItem(f, self.ui.pageList)
          item.setIcon(icon)
          item.setStatusTip(f)

        return True
Run Code Online (Sandbox Code Playgroud)

另外,正如您在代码中看到的那样,也是一个侧面问题f = str(file[-1]).我必须在每次调用方法时从我删除的文件数组中选择最后一个元素,因为每次丢弃的文件都会调用它,即使它们一次全部删除也是如此.这有什么理由/解决方法吗?

谢谢!

Mar*_*som 5

您可以尝试使缩略图更快,但这只会增加您在发现问题之前可以放下的书的大小.答案是仅显示页面的缩略图,或将缩略图降级为后台线程,并在每个完成时更新显示.