[PyQt] Re: Global Shorcuts

Hans-Peter Jansen hpj at urpla.net
Wed Nov 4 09:58:27 GMT 2009


On Wednesday 04 November 2009, 08:42:17 Wolfgang Rohdewald wrote:
> On Wednesday 04 November 2009, Manuel Enrique wrote:
> > How can I set a global shorcut for my app?
>
> look up setShortcutContext in the docu:
>
> res = KAction(self)
> # should also work with QAction, I suppose
> res.setShortcut( Qt.CTRL + shortcut)
> res.setShortcutContext(Qt.ApplicationShortcut)

Manuel, does this work for you? I guess you're after global desktop 
shortcuts, often combined with a systray app, similar to klipper and kding.

I haven't checked PyQt4 yet, but for PyQt3 it indeed involved in speaking to 
the window manager directly, which is highly unportable, and depending on 
discretion of the various WMs :-(...

PyKDE may be helpful here, but for my app, I needed reliable global 
(desktop) shortcuts _without_ depending on PyKDE, so it does depend on 
ctypes now. Be assured, that unlike PyQt, Xlib programming with ctypes 
isn't funny at all (highly understating)..

Let us know about your findings,
Pete



More information about the PyQt mailing list