View Single Post
Old 02-17-2010, 08:04 AM   #13
GRiker
Comparer of the Ephemeris
GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.
 
Posts: 1,496
Karma: 424697
Join Date: Mar 2009
Device: iPad
Here's a template that lets you display a simple dialog:

Code:
import os
from calibre.customize import FileTypePlugin

class HelloWorld(FileTypePlugin):

    name                = 'HelloWorld'
    description         = 'A shell for creating plugins'
    supported_platforms = ['windows', 'osx', 'linux']
    author              = 'your_name_here'
    version             = (1, 0, 0)
    file_types          = set(['your_file_type_here'])
    on_import           = True 

    def run(self, path_to_ebook):
        from calibre.gui2 import is_ok_to_use_qt
        from PyQt4.Qt import QMessageBox

        if is_ok_to_use_qt():
            QMessageBox.question( None, 
                        'Hello World Plugin', 
                        "path_to_ebook: %s" % path_to_ebook,
                         QMessageBox.Ok)

        return path_to_ebook
I believe if you return None calibre understands that the import failed.

G
GRiker is offline   Reply With Quote