View Single Post
Old 06-10-2025, 11:20 PM   #3
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,984
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
Quote:
Originally Posted by kovidgoyal View Post
I'm surprised this ever worked. In Qt the "correct" way to update the UI while also busy looping in the GUI thread is to periodically call QApplication.processEvents(ExcludeUserInputEvents)

You can do that after every call to update the status bar. Repainting it directly should also work provided you are careful to ensure no recursion occurs. I wont accept a PR to have show_message() repaint directly because this is dangeroud, if a user of show_message() happens to call it froma paintEvent, it can lead to infinite recursion and a crash.
Thanks. I figured there was probably a better way, but I didn't know what it was.

For the record, this appears to work from Calibre 2.85.1 forward:
Code:
from PyQt5.Qt import (QApplication, QEventLoop)
#...
    self.gui.status_bar.show_message('message')
    QApplication.processEvents(QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents)
timeout param still doesn't work, but since to whole point (for me) is "Doing" ... "Done", that's fine.

BTW, I went back and checked--it definitely worked in 2.85.1.
JimmXinu is offline   Reply With Quote