
import signal
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import GLib, Gtk


def value_changed(adj):
    print("value-changed %.1f" % adj.get_value())

a = Gtk.Adjustment()
a.connect('value-changed', value_changed)

t = Gtk.TextView()
t.get_buffer().set_text('foo\n' * 100)

sw = Gtk.ScrolledWindow()
sw.set_vadjustment(a)
sw.add(t)

w = Gtk.Window()
w.add(sw)
w.show_all()
w.connect('delete-event', lambda *x: Gtk.main_quit())

GLib.idle_add(lambda: a.set_value(100.5))

GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT,
                     lambda *args: Gtk.main_quit(), None)
Gtk.main()
