[pygtk] Questions about accelerators.
Fri, 29 Sep 2000 17:25:39 +0200 (CEST)
On Fri, 29 Sep 2000, Dave Belfer-Shevett wrote:
> ta = widgets.get_widget('sp_sendtext')
> Which triggers
> def sendkey():
> print "Key pressed! "
> return FALSE
> But I get:
> [shevett@cheetah]:~/python/spanker/proj1$ ./spanker.py
> Traceback (innermost last):
> File "/usr/local/lib/python1.5/site-packages/gtk.py", line 125, in
> ret = apply(self.func, a)
> TypeError: no arguments expected
> Wha'd i do wrong?
your handler takes no argument, and gtk tries to call it with arguments,
hence the error.
You could do
if you don't care about which key was pressed, or
if you want to get some info. The key event has the following
fields (from the gtk documentation project):
the type of the event (GDK_KEY_PRESS or
the window which received the event.
TRUE if the event was sent explicitly (e.g. using XSendEvent).
the time of the event in milliseconds.
a bit-mask representing the state of the modifier keys (e.g. Control,
Shift and Alt) and the pointer buttons. See GdkModifierType.
the key that was pressed or released. See the <gdk/gdkkeysym.h> header
file for a complete list of GDK key codes.
the length of string.
a null-terminated multi-byte string containing the composed characters
resulting from the key press. When text is being input, in a GtkEntry for
example, it is these characters which should be added to the input buffer.
When using Input Methods to support internationalized text input, the
composed characters appear here after the pre-editing has been completed.
Alexandre Fayolle http://www.logilab.com - "Mais oł est donc Ornicar ?" -
LOGILAB, Paris (France).