Dang, that is sweet!
Looks like fun.

Thanks,
Kent


On Tue, Jun 30, 2009 at 10:15 AM, Ville M. Vainio<[email protected]> wrote:
>
> Yay, qt rclick is finally here :-). Except that it's not a plugin, nor
> should it ever be a plugin. It's a simple entry point in qtGui that
> allows plugins to create context menu items. It does
> not bring the functionality of tk rclick plugin to qt (nor should it -
> a separate plugin can do that). But, I think this approach is simpler
> than the tk rclick (easier to write plugins, and *zero* wrapping is
> done - you can create submenus, icons, tooltips, do whatever is
> supported by QMenu/ QAction as you wish).
>
> Here's an example "plugin" script (just enter it in node and press ctrl+b):
>
> QQQ
>
> #Example popup handler
> from PyQt4 import QtCore
>
> def test_acts(c,p,menu):
>
>    # 'menu' is QMenu instance that was jsut created
>    a1 = menu.addAction("Display " + p.h)
>    a2 = menu.addAction("Es " + p.h)
>
>    def a1_func():
>        g.es("a1 from " + p.h)
>
>    def a2_func():
>        g.es("a2 from " + p.h)
>
>    a1.connect(a1, QtCore.SIGNAL("triggered()"), a1_func)
>    a2.connect(a2, QtCore.SIGNAL("triggered()"), a2_func)
>
> def test_acts_handler2(c, p, menu):
>    a = menu.addAction("Hello from handler 2")
>    def f():
>        g.es("Hello: " + p.h)
>
>    a.connect(a, QtCore.SIGNAL("triggered()"), f)
>
> def register():
>    # the idea is just to append to the normal list g.tree_popup_handlers
>    g.tree_popup_handlers.append(test_acts)
>    g.tree_popup_handlers.append(test_acts_handler2)
>
> register()
>
> QQQ
>
> The idea is indeed a list of functions / callables
> g.tree_popup_handlers. When you are creating a plugin, just add your
> menu manipulation routines to that list. It should be done in plugins
> "init" (not after-create-leo-frame handler), because the handlers are
> global.
>
> If there is demand, we can add "priority" to handlers, but at the
> moment this will suffice.
>
> Relevant Qt docs:
>
> http://doc.trolltech.com/4.5/qmenu.html
> http://doc.trolltech.com/4.5/qaction.html
>
> So far, this is only for tree. We can add different rclick handlers
> for body (body_popup_handler / whatever).
>
> BTW jkn, I realize you were working on this too - do you have
> something that could be "synced" with this approach (e.g. wrapping
> rclick.py stuff so existing Tk plugins would work)?
>
> --
> Ville M. Vainio
> http://tinyurl.com/vainio
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to