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 05-01-2024, 10:06 AM   #1
feuille
Connoisseur
feuille will become famous soon enoughfeuille will become famous soon enoughfeuille will become famous soon enoughfeuille will become famous soon enoughfeuille will become famous soon enoughfeuille will become famous soon enough
 
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()
This will display the Calibre error dialog. So good so far...

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.
feuille is offline   Reply With Quote
Old 05-01-2024, 10:11 AM   #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: 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.
kovidgoyal is offline   Reply With Quote
Advert
Old 05-01-2024, 02:03 PM   #3
thiago.eec
Wizard
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 1,082
Karma: 1221485
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
Quote:
Originally Posted by feuille View Post
Code:
d = error_dialog(self.gui, 'MyGuiPlugin', _('No book selected!'))
d.exec()
I usually do it like this:

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)
This will exit some_function.
thiago.eec is offline   Reply With Quote
Reply


Forum Jump

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


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


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