Ubuntu: Glade: How can I set the value of a spin button?



Question:

I've done some spin buttons with Glade for my Python/GTK3 app, but I don't know how to set things like default, lower or higher value. How can I do it?

Using the following things for development:

  • Python 2.7.3
  • GTK 3
  • Glade 3.12.1

1) I need to change things from script, as I need to set default value and maximum value as a variable;

2) I saw the PyGTK documentation before, it's not working for GTK3;

3) please don't direct me to the GTK3 docummentation... I can't understand it :P


Solution:1

In Glade:

  1. Select the spinbutton.
  2. Click the button next to the "Adjustment" text entry that has "..." in it.
  3. In the window that appears click "New."
  4. Select the "adjustment1" widget from above.
  5. From there you can change value for a default value, minimum value, maximum value, and step increment.

You can also change those values from code, the class refrence can be found here: gtk.SpinButton.

Edit: You can get the maximum and minimum values using the following code:

(min, max) = spinbutton.get_range()  

where min is minimum value, max is maximum value, and spinbutton is the spin button widget. You can also set it using the following:

spinbutton.set_range(min, max)  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »