[pygtk] ActionGroup versus Keypress event
Doug Blank
doug.blank at gmail.com
Sat Aug 14 23:15:36 WST 2010
Hello,
Looking for a little guidance on how to handle control+c in a pygtk application.
Currently, I have defined an ActionGroup with copy and paste. This
allows us to handle the control+c to move objects around, and also
shows the items on the menu.
However, this prevents control+c from working inside a text editing area.
What is the best way to handle control+c sometimes, but other times,
let gtk pass it around and handle it?
I have tried to emit a keystroke inside the ActionGroup associated
code, but it never appears (the print occurs, but no event is handled
by the text edit area):
def call_copy(self):
print "emit copy!"
e = gtk.gdk.Event(gtk.gdk.KEY_PRESS)
e.keyval = gtk.keysyms.c
e.state = gtk.gdk.CONTROL_MASK
e.window = self.uistate.window.window
e.send_event = True
self.uistate.window.get_focus().emit("key-press-event", e)
return
Is there a better way that will make all of the text areas work, show
the control+c on the menu, but still allow us to handle it on
occasion?
Thanks for any insight,
-doug
More information about the pygtk
mailing list