05-01-2024, 10:06 AM | #1 |
Connoisseur
Posts: 59
Karma: 666
Join Date: May 2020
Location: Germany
Device: android smartphone + tablet
|
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. |
05-01-2024, 10:11 AM | #2 |
creator of calibre
Posts: 44,542
Karma: 24495948
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 | |
|
05-01-2024, 02:03 PM | #3 | |
Wizard
Posts: 1,082
Karma: 1221485
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
|
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] Noosfere_util, a companion plugin to noosfere DB | lrpirlet | Plugins | 2 | 08-18-2022 04:15 PM |
[GUI Plugin] Manga plugin | mastertea | Plugins | 6 | 01-06-2022 03:43 AM |
[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 |