![]() |
#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. |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,893
Karma: 26594726
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,169
Karma: 1270433
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) |
|
![]() |
![]() |
![]() |
|
![]() |
||||
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 |