View Single Post
Old 11-27-2010, 07:40 PM   #14
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,017
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Here you go:

Code:
#!/usr/bin/env python
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai

__license__   = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'


from calibre.customize import InterfaceActionBase

class HelloWorldBase(InterfaceActionBase):

    name = 'Hello World GUI'
    author = 'The little green man'

    def load_actual_plugin(self, gui):
        from calibre.gui2.actions import InterfaceAction

        class HelloWorld(InterfaceAction):
            name = 'Hello World GUI'
            action_spec = ('Hello World!', 'add_book.png', None,
                    _('Ctrl+Shift+H'))

            def genesis(self):
                self.qaction.triggered.connect(self.hello_world)

            def hello_world(self, *args):
                from calibre.gui2 import info_dialog
                info_dialog(self.gui, 'Hello World!', 'Hellooo World!',
                        show=True)

        return HelloWorld(gui, None)
Add this plugin and press Ctrl+Shift+H in the gui to see a nice Hello World popup
kovidgoyal is offline   Reply With Quote