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