An alternative is to grab the common_utils.py from one of kiwidudes plugins, or one of mine. This has a ProgressBar implementation. Here is how it is called:
Code:
pb = ProgressBar(parent=self.gui, window_title=_("Removing annotations"), on_top=True)
total_books = len(db.data)
pb.set_maximum(total_books)
pb.set_value(0)
pb.set_label('{:^100}'.format(_("Scanning {0} of {1}").format(0, total_books)))
pb.show()
for i, record in enumerate(db.data.iterall()):
pb.set_label('{:^100}'.format(_("Scanning {0} of {1}").format(i, total_books)))
pb.increment()
# Do whatever
# Hide the progress bar
pb.hide()
This is modal and can't be cancelled. Overall, probably no simpler as it relies on another class, but it feels simpler when actually using it.