[pygtk] strange spinbutton behavior
James Dietrich
jdietrch at gmail.com
Thu Jun 28 07:50:53 WST 2007
On 6/27/07, JUAN JOSE ROJO <jjrojoc at gmail.com> wrote:
> Sorry, i forget this
>
> 2007/6/28, JUAN JOSE ROJO <jjrojoc at gmail.com>:
> >
> >
> >
> > 2007/6/27, James Dietrich <jdietrch at gmail.com>:
> > > 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)
> >
>
> adj = gtk.Adjustment(1, 1, 100, 2, 1, 0)
> With that should work jumping two digits.
>
> >
> >
> > > spin = gtk.SpinButton(adj, 0, 0)
> > > spin.connect('value-changed', adj_callback)
> >
> >
> > spin.connect('change-value', adj_callback)
> >
> >
> > > spin.show()
> > >
> > > win.add(spin)
> > > win.show()
> > >
> > > gtk.main()
Hi,
Thanks for the suggestions, but it's not what I need.
Perhaps I didn't explain myself well enough.
In the original example, I want and expect that the spinbutton
should advance one digit at a time by clicking on the tiny
arrows.
It does work as expected if the adj_callback executes quickly,
like if I uncomment the return statement in there.
However, if that long loop executes in the callback (it takes
several seconds at least), then the spinbutton advances by
two digits for every one click.
Any more ideas on how to make the spinbutton only advance
one digit at a time even if the callback takes several seconds?
Thanks for your help,
James Dietrich
More information about the pygtk
mailing list