I'm working (still) on a book binding application, and to make it aesthetically pleasing, I've added a thumbnail to every page you drag in. It works just fine, but the only problem is that when I drag in a whole book (i.e. 400 images), it freezes completely until it's done.
Here's my simple drop code:
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
Also, just as a side question, as you can see in the code, f = str(file[-1])
. I have to select the last element from my dropped files array every time the method is called, as it is called for every file dropped, even if they are dropped all at once. Is there a reason/workaround for this?
Thank you!
You could try to make the thumbnailing faster, but that would only increase the size of the book that you could drop before you'd notice the problem. The answers are to either only thumbnail a page as it's displayed, or relegate the thumbnailing to a background thread and update the display as each is finished.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With