Dhiraj Thakur(Invincible)
June 24th, 2011, 01:30 PM
hi all i hav written a code in pygtk that captures the keys that a user presses while the widget is running..but only when it is in focus...so is thre anything which can make it run without it in focus....???
the code is
import pygtk,gtk
def on_key_press_event(widget, event):
keyname = gtk.gdk.keyval_name(event.keyval)
print "Key %s (%d) was pressed" % (keyname, event.keyval)
w = gtk.Window()
w.connect('key_press_event', on_key_press_event)
w.show_all()
w.connect("destroy",lambda wid:gtk.main_quit())
gtk.main()
the code is
import pygtk,gtk
def on_key_press_event(widget, event):
keyname = gtk.gdk.keyval_name(event.keyval)
print "Key %s (%d) was pressed" % (keyname, event.keyval)
w = gtk.Window()
w.connect('key_press_event', on_key_press_event)
w.show_all()
w.connect("destroy",lambda wid:gtk.main_quit())
gtk.main()