[PyQt] [PyKDE4] Default value for the second argument of
KAction.setShortcut() does not seem to work
Simon Edwards
simon at simonzone.com
Sat Jan 12 10:40:53 GMT 2008
Hi,
Adeodato Simó wrote:
> This one time, I'm finding that KAction.setShortcut() can't work in
> Python without passing a value for the second argument, whereas this
> works in C++. Any chance you'd know why? Thanks.
Looks like a bug in PyKDE4. The second arg doesn't have a default value
like in the C++ version. I'll try to get this fixed in 4.0.1.
> This:
>
> -8<-
> #! /usr/bin/env python
>
> from PyKDE4 import kdeui
>
> action = kdeui.KAction(None)
> action.setShortcut(kdeui.KShortcut('Ctrl+F'))
Add the second arg like this (and close your eyes):
action.setShortcut(kdeui.KShortcut('Ctrl+F'),
kdeui.KAction.ShortcutTypes( \
kdeui.KAction.ShortcutTypes(kdeui.KAction.ActiveShortcut) | \
kdeui.KAction.ShortcutTypes(kdeui.KAction.DefaultShortcut)))
This fix will work in the future and has the same effect as the fixed
version.
mmm... it would be nice if PyQt4's QFlags() accepted a uint mask in its
constructor. If would save a lot of ugly Python code, for the price of a
little bit of runtime type safety...
Thanks for the great bug report.
cheers,
--
Simon Edwards | KDE-NL, Guidance tools, Guarddog Firewall
simon at simonzone.com | http://www.simonzone.com/software/
Nijmegen, The Netherlands | "ZooTV? You made the right choice."
More information about the PyQt
mailing list