View Single Post
Old 08-18-2012, 06:05 PM   #2
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Have a look at the Quality Check plugin source code - specifically "dialogs.py" and copy/modify the "QualityProgressDialog" class which is at the top of the file. Basically you just do your work inside that "do_book_action" function, and that self.i counter and self.setValue stuff increments the progress bar, using QTimer.singleShot to ensure it pumps the message threads to keep the UI updated while it does the work.

It is invoked from the check_base.py file, inside the "check_all_files" function - just a case of instantiating it passing in whatever parameters it needs to do the work. In the case of this plugin it passes in a callback_fn parameter, being a function pointer reference to a dynamically chosen function (since the same dialog is redisplayed for a whole range of different purposes) but you can ignore that and do the work inside the dialog itself if you want as I mentioned above.

It is a pattern I have used over and over again in my plugins, many of them have it.
kiwidude is offline   Reply With Quote