Hi.
I'm trying to handle key_press_events for widgets that don't have their
own GdkWindow (e.g. a GtkLabel).
The following snippet of code attempts to capture mouse clicks and key
presses on the label, by wrapping the label in a GtkEventBox. It works
with the button_press_event, but not the key_press_event.
import gtk, GDK
window = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL)
label = gtk.GtkLabel()
label.set_text("Press a key, any key...")
ebox = gtk.GtkEventBox()
ebox.add(label)
ebox.set_events(GDK.KEY_PRESS_MASK | GDK.BUTTON_PRESS_MASK)
ebox.connect("button_press_event", gtk.mainquit)
ebox.connect("key_press_event", gtk.mainquit)
ebox.realize()
window.add(ebox)
window.show_all()
gtk.mainloop()
I'm fairly new to this, am I doing anything wrong? I'm using PyGTK 0.6.8
on Python 2.2.
--
Graham Ashton
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/