|
|
#1 |
|
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() Posts: 64
Karma: 666
Join Date: May 2020
Location: Germany
Device: android smartphone + tablet with Moon Reader and ReadEra Apps.
|
Exit GUI Plugin
Sorry if this is a stupid question: But how do I exit a GUI plugin without starting the main dialog if an error occurs during initialization?
Example: If the user has not selected a book, I print the following message in the __init__ method of class MyGuiPluginDialog(QDialog): Code:
d = error_dialog(self.gui, 'MyGuiPlugin', _('No book selected!'))
d.exec()
But how do I stop executing the plugin at this point? "return" shows the error dialog again, after "OK" the main dialog of the plugin is shown. "sys.exit()" closes Calibre itself. |
|
|
|
|
|
#2 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,610
Karma: 28549044
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You perform the check before creating your dialog, and return from whatever function you are creating the dialog in.
|
|
|
|
| Advert | |
|
|
|
|
#3 | |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,293
Karma: 1428313
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
|
Quote:
Code:
from calibre.gui2 import error_dialog
def some_function():
do_stuff
if some_condition:
return error_dialog(self.gui, 'MyGuiPlugin', _('No book selected!'), show_copy_button=False, show=True)
|
|
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [GUI Plugin] Manga plugin | mastertea | Plugins | 7 | 10-30-2025 01:13 AM |
| [GUI Plugin] Noosfere_util, a companion plugin to noosfere DB | lrpirlet | Plugins | 2 | 08-18-2022 04:15 PM |
| [GUI Plugin] Save Virtual Libraries To Column (GUI) | chaley | Plugins | 14 | 04-04-2021 06:25 AM |
| [GUI Plugin] Plugin Updater **Deprecated** | kiwidude | Plugins | 159 | 06-19-2011 01:27 PM |