Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old Yesterday, 06:24 PM   #1
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,902
Karma: 4604435
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
Status Bar Show Message

My plugins use self.gui.status_bar.show_message(msg) in a number of places to indicate what's going on without throwing up a dialog. Things like "Fetching email..." and "Get stuff from web page..." and frequently a matching "Finished Fetching whatever" message when it's done, with a timeout of a few seconds.

I know that all worked when I put them in--and I admit that was a long time ago.

I've noticed more recently that the 'Finished' messages appear, but not the 'Fetching' messages.

Experimentation indicates that status_bar.show_message() calls don't update the GUI until my action/function returns back to Qt/Calibre. If I turn on notifications, I do get all the messages there.

So I suspect that Qt is not updating the status_bar widget until the GUI thread gets back to it's control.

I can brute-force it by calling status_bar.repaint() in my code, or adding a repaint call in src/calibre/gui2/init.py:237. (In both cases, the timeout isn't honored anymore.)

Kovid, would you accept a PR add repaint() like that? Is there a better fix?

FYI, I'm using Cal 8.4 on Win10.
JimmXinu is offline   Reply With Quote
Old Yesterday, 09:37 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,253
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
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.

Last edited by kovidgoyal; Yesterday at 09:43 PM.
kovidgoyal is offline   Reply With Quote
Advert
Old Yesterday, 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,902
Karma: 4604435
Join Date: Dec 2011
Location: Midwest USA
Device: Kindle Paperwhite(10th)
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
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Any way to show only current page number and percentage on bottom status bar? ereader_User KOReader 1 05-10-2022 09:58 AM
Show status Bar in Apps p3l4h0 Onyx Boox 0 02-08-2020 08:10 AM
How can I show top bar (status bar) on the Nova Pro with the new firmware (2.2.1)? SeanMcNally Onyx Boox 9 12-30-2019 09:16 AM
Suggestion - KOREADER - mini bar - show light-status / percentage Sisela KOReader 1 01-30-2016 09:39 AM
Show the Status bar always tochill Marvin 7 09-16-2013 09:53 PM


All times are GMT -4. The time now is 07:22 AM.


MobileRead.com is a privately owned, operated and funded community.