import gi

gi.require_version('Gtk', '3.0')

from gi.repository import Gtk


def callback(entry, new_text, new_text_length, position):
    print new_text, new_text_length, position

win = Gtk.Window()

entry = Gtk.Entry()
entry.connect('insert-text', callback)
entry.set_text('Test')
win.add(entry)

win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
