[pygtk] Generating Keyboard Events
Nikos Kouremenos
kourem at gmail.com
Wed Mar 15 08:06:56 WST 2006
On 3/14/06, Chris Gonnerman <chris.gonnerman at newcenturycomputers.net> wrote:
> Can anyone give me some guidance on generating keyboard events? There
> are a couple of widgets that just don't work to suit me, and which
> cannot (so far as I can tell) be directly overridden; the
> gtk.EntryCompletion is my #1 pet peeve, for how it handles Tab. I'd
> like to catch the keystroke (which I know how to do), nullify it (which
> I think I know how to do), and generate a Return and a Tab and have them
> handled in that order (I'll need to keep a flag to prevent the synthetic
> Tab from making the whole mess loop).
>
> But I'm not having any luck finding guidance for creating synthetic
> keyboard events.
>
> Anybody?
event = gtk.gdk.Event(gtk.gdk.KEY_PRESS) # it's always a key-press here
event.keyval = gtk.keysyms.Return
event.state = gtk.gdk.CONTROL_MASK
event.time = 0 # assign current time
widget_that_should_accept_signal.emit('key_press_event', event)
I put those in an FAQ
--
Nikos Kouremenos
More information about the pygtk
mailing list