At the risk of the blind leading the blind, this is what I did after having looked at kiwidude's Quality Check code.
I used a QProgressDialog rather than QProgressBar.
This was the dialog:
Code:
class CoverProgressDialog(QProgressDialog):
def __init__(self, gui, total_books, some_more_params):
self.total_books = total_books
QProgressDialog.__init__(self, '', QString('Cancel'), 0, self.total_books, gui)
self.gui = gui
# ... ...
self.i = 0
# ... ...
QTimer.singleShot(0, self.do_book_action)
self.exec_()
def do_book_action(self):
if self.wasCanceled():
return self.do_close()
if self.i >= self.total_books:
return self.do_close()
# code for processing a single book ...
self.i += 1
self.setLabelText('%d of %d' % (self.i, self.total_books))
self.setValue(self.i)
QTimer.singleShot(0, self.do_book_action)
def do_close(self):
self.hide()
self.gui = None
and this was the code which called the dialog
Code:
dlg = CoverProgressDialog(self.gui, total_books, some_more_params)
if dlg.wasCanceled():
# do whatever should be done if user cancelled
Hope this helps