View Single Post
Old 08-15-2018, 08:16 AM   #4
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
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.
davidfor is offline   Reply With Quote