import gtk, gobject def on_button_key_press (button, event): popup.show_all () # Just make sure the popup is shown, quick and dirty print "Button Key Press" focus_event = gtk.gdk.Event (gtk.gdk.FOCUS_CHANGE) focus_event.in_ = True popup.emit ("focus-in-event", focus_event) popup.event (event) win = gtk.Window () popup = gtk.Window (gtk.WINDOW_POPUP) button = gtk.Button ("Just start typing!") button.connect ("key-press-event", on_button_key_press) win.connect ("destroy", gtk.main_quit) entry = gtk.Entry () win.add (button) popup.add (entry) win.show_all () gtk.main ()