View Full Version : Problem with gtk.Scale

June 5th, 2009, 03:07 AM
Consider the following small python script:

#!/usr/bin/env python
import gobject, gtk

val = 0
def timeout():
global val
val +=1
return True

win = gtk.Window()
scale = gtk.HScale()

scale.set_range(0, 100)

gobject.timeout_add(1000, timeout)

All works as expected: the slider moving and label updating every second. Now instead of 0 - 100, use a range of 0 - 10000, and the label isn't update anymore every second.

Edit: I will use my own label, instead of the one provided by the scale. as a work around.

June 5th, 2009, 03:49 AM
Presumably, the reason it's not updating is that 1/10000 is not nearly enough to move the slider, so it doesn't bother updating the text either. The text will eventually update when the indicator moves by a pixel. If you really need the number to be precise, turn off the value display (set_draw_value) and handle it yourself with something like a label.

BTW, what are you using the HScale for? Is this a progress meter for a video/audio player?

June 5th, 2009, 04:29 AM
Yes the scale is used as a progress meter and for seeking purposes.

August 27th, 2010, 08:55 AM

I also have a problem with gtk.Scale. I'm using c++ as programming language but that shouldn't matter I think.

I've setup a callback for when te value of gtk.Scale changes. The callback get's triggered because maxHue gets updated but the set_value on the slider isn't performed. The code looks as follows:

void on_sliderHueMax_value_changed(Gtk::ScrollType scroll, double new_value) {
if(new_value < minHue){
new_value = minHue;
maxHue = (int) new_value;
/*Could below I just for forcing redraw but doesn't work either*/
Gtk::Allocation alloc = pSliderHueMax->get_allocation();
int x = alloc.get_x();
int y = alloc.get_y();
int width = alloc.get_width();
int height = alloc.get_height();


(Some background information: I just want to have 2 sliders, 1 for the maximum value and 1 for the minimum value and I want to make sure the user is not able to select a minimum value that's higher than the maximum value and vice versa.)

Anyone who has got an idea?

August 27th, 2010, 11:11 AM
Running on Gentoo stable this bug does not appear and I do consider this a bug.

August 27th, 2010, 01:27 PM
Ok, thank you for the information.

So normally (if the bug wouldn´t exist).

should be enough?