我正在(仍在)装订应用程序,并且为了使其美观,我在拖动的每个页面上都添加了一个缩略图。它工作得很好,但是唯一的问题是当我整体拖动时书(即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

同样,正如附带的问题一样,您可以在代码f = str(file[-1])中看到。每次调用该方法时,我都必须从删除的文件数组中选择最后一个元素,因为每个删除的文件都会调用该方法,即使它们一次全部删除也是如此。是否有理由/解决方法?

谢谢!

最佳答案

您可以尝试加快缩略图的显示速度,但这只会增加在您发现问题之前可以放下的书的大小。答案是只显示页面缩略图,或者将缩略图放到后台线程中,并在每个页面完成后更新显示。

关于python - 如何使用PyQT4(快速)缩图300张图像?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4589390/

10-13 05:41