from gi.repository import Gtk

def on_insert_text(editable, new_text, new_text_length, position, user_data):
    print "Text inserted"

window = Gtk.Window()
window.connect("delete-event", Gtk.main_quit)

entry = Gtk.Entry()
entry.connect('insert-text', on_insert_text, None)
entry.set_text("Hello World")
window.add(entry)

entry.show()
window.show()

Gtk.main()

