![]() |
#16 |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 74,015
Karma: 315160596
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
|
![]() |
![]() |
![]() |
#17 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,385
Karma: 27756918
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
The plugin should either raise an exception or return the original file path on failure.
Make your message box non modal, it will then not interrupt the adding process and will still be there when the adding dialog closes. EDIT: Actually, no that wont work, since the message box is cerated ina separate process that dies after adding is done Instead you can try calling self.raise_() Last edited by kovidgoyal; 02-17-2010 at 01:58 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#18 |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 74,015
Karma: 315160596
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
self.raise() gives a syntax error, and self.raise_() presumably generated an exception (since my dialog no longer appeared at all).
Here's my code that gets run when I've had to give up on converting a file: Code:
if is_ok_to_use_qt(): #self.raise_() QMessageBox.question( None, 'My Plugin', "Couldn't convert: %s\nImporting original version instead." % path_to_ebook, QMessageBox.Ok) return path_to_ebook |
![]() |
![]() |
![]() |
#19 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,385
Karma: 27756918
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You're using a pre-built messagebox, in that case raise wont work. WHat you have to do is construct your own messagebox and call raise_ on it
Code:
d = QMessageBox(QMessageBox.Warning, 'title', 'message') d.raise_() d.exec_() |
![]() |
![]() |
![]() |
#20 | |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 74,015
Karma: 315160596
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
Quote:
I've attached a very simple plug-in that demonstrates the problem. I have no notion of how to get any further with this. |
|
![]() |
![]() |
Advert | |
|
![]() |
#21 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,385
Karma: 27756918
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Do the following:
Code:
d = QMessageBox(QMessageBox.Warning, 'title', 'message') d.show() d.raise_() |
![]() |
![]() |
![]() |
#22 | |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 74,015
Karma: 315160596
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
Quote:
d.show() d.raise_() d.exec_() did bring the MessageBox to the front of the "Adding..." dialog. If I could find a way to leave messages up in a non-modal fashion behind the "Adding..." dialog, I can ses that that would be better for when people want to import loads of files and just leave it running. But I'm happy for now. |
|
![]() |
![]() |
![]() |
#23 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,385
Karma: 27756918
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
d.setModal(False)
before the call to exec_ |
![]() |
![]() |
![]() |
#24 |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 74,015
Karma: 315160596
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
This does make the dialog non-modal, but it doesn't allow exec_() to return until after the OK button has been pressed - so an error still blocks the import.
It seems to be that I really need to be able to put the message box into its own thread or something. But reading up on QT in python, is seems to be the case that all GUI interactions must be in the main thread. Thanks for all your suggestions. I think that warning of the problem is more important than not interrupting a large import, so I'll stick to the modal dialog for now. |
![]() |
![]() |
![]() |
#25 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,385
Karma: 27756918
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
If you dont want the dialog to block, dont call exec_
Just calling show will be enough to show the dialog. |
![]() |
![]() |
![]() |
#26 |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 74,015
Karma: 315160596
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
|
![]() |
![]() |
![]() |
#27 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,385
Karma: 27756918
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Strange...do me a favor and open a ticket about it, and I'll add a generic mechanism plugins can use to display messages to the user.
|
![]() |
![]() |
![]() |
#28 |
The Grand Mouse 高貴的老鼠
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 74,015
Karma: 315160596
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Oasis
|
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Issues importing mobi books from Fictionwise. | splat | Calibre | 14 | 02-22-2010 02:35 AM |
Error importing epub book to calibre and ipod touch | BigHoss | Calibre | 0 | 01-24-2010 10:21 AM |
unencrypted azw books - error importing | abrinton | Calibre | 4 | 01-19-2010 02:57 PM |
Error when importing MobiPocket files. | mbovenka | Calibre | 7 | 08-16-2008 10:07 AM |
Importing multiple files into Mobi Reader | Calamity | Bookeen | 0 | 07-25-2008 10:57 AM |