Gtk_adjustment_set_upper - not doing what I expect

Hi all. I’m having trouble setting an upper limit for a Gtk.Adjustment. In Python, I’m creating an adjustment and a spinbutton:

adjustment = Gtk.Adjustment.new( 1 , 1 , 200 , 1 , 10, 10 )
self.spinner = Gtk.SpinButton.new( adjustment , 1 , 0 )

This works so far - or mostly anyway. I’m able to alter values in the spinbutton from 1 through to 190. Why can’t I set values up to 200? Have I created the adjustment incorrectly?

Anyway … later on in my app ( when I fetch some data ), I want to change the upper limit. I’m doing:

adjustment = self.spinner.get_adjustment()
record_count = len( self.model )
print( "set_spinner_range: we have {0} records".format( record_count ) )
adjustment.set_upper( record_count )

This results in the spinbutton being locked to 1. The value of record_count that I’m testing with here is 3, by the way. So I expected to be able to set values from 1 through to 3. What am I doing wrong?

You set the page size to a non-zero value; that will change the behaviour of Gtk.Adjustment.set_upper().

Set a page size of zero.

Thank you Emmanuele!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.