[pygtk] strange spinbutton behavior

James Dietrich jdietrch at gmail.com
Thu Jun 28 04:38:32 WST 2007


Hi,

In the following program, one click on the spinbutton will
advance the number displayed by two digits--from '1' to '3'.
Apparently the 'value-changed' signal gets emitted twice
when the adj_callback takes some time to do. If I uncomment
the line with 'return' on it so that it skips the long loop, one
click advances the number on the spinbutton by one
number, as expected.

Am I missing something about how spinbuttons work?

Thanks for your help,
James Dietrich

import gtk

def adj_callback(adj):
	print "Adj Callback"
	#return
	for x in range(10000000): y = x * x

win = gtk.Window()
win.connect('delete-event', gtk.main_quit)

adj = gtk.Adjustment(1, 1, 100, 1, 1, 0)
spin = gtk.SpinButton(adj, 0, 0)
spin.connect('value-changed', adj_callback)
spin.show()

win.add(spin)
win.show()

gtk.main()


More information about the pygtk mailing list