【发布时间】:2011-06-03 03:04:57
【问题描述】:
我正在(仍在)开发书籍装订应用程序,为了使其美观,我为您拖入的每个页面添加了一个缩略图。它工作得很好,但唯一的问题是当我拖动在整本书(即 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 问题。我会浏览一下。
标签: python drag-and-drop thumbnails pyqt4