[pygtk] SpinButton and a value of None

N. Volbers mithrandir42 at web.de
Fri Nov 25 04:33:26 WST 2005

Hello everyone,

I replaced some gtk.Entry widgets by the more appropriate gtk.SpinButton 
widgets.  'More appropriate' means that the user needs to enter an 
integer number > 0 and a spin button seemed predetermined for this.

My first problem, which I finally solved, was that I have to set both a 
maximum and a minimum limit, so instead of specifying just


I have to use something like

   widget.set_range(min=0, max=sys.maxint)

My second problem arises due to the fact that it should be possible  to 
specify no value at all.  This was easy for an entry widget: If the 
length of the text equals to zero, then I knew the text field was empty 
and I would set my internal value to None.  However I could not find a 
way to let the user delete the contents of a spin button.  Whenever I 
delete its contents it gets replaced by the last valid value again.

Am I missing something obvious? I would appreciate any suggestions on this.


Niklas Volbers.

More information about the pygtk mailing list