Catskul
Catskul

Reputation: 19239

Possible to set fill level below value for Gtk::Scale?

While it's strightforward to set the fill level above the Scale's value using set_fill_level setting the fill level below the Scale's value does not appear to work.

To clarify I'd like to, for instance, be able to set the fill level to 25% while the slider is at 50%

FFFF----S-------

or alternately:

Extra details:

Images of the undesired behavior:

enter image description here

enter image description here

Upvotes: 2

Views: 878

Answers (1)

Johannes Sasongko
Johannes Sasongko

Reputation: 4228

You just need to disable the restriction:

Additionally, it's possible to restrict the range's slider position to values which are smaller than the fill level. This is controller [sic] by gtk_range_set_restrict_to_fill_level() and is by default enabled.

(Source)

Update: Example:

GtkHScale with fill-level=3 and value=5

import gtk

s = gtk.HScale()
s.set_show_fill_level(True)
s.set_restrict_to_fill_level(False)  # <=====
s.set_range(0, 10)
s.set_fill_level(3)
s.set_value(5)

w = gtk.Window()
w.connect('destroy', lambda *x: gtk.main_quit())
w.add(s)
w.show_all()
gtk.main()

Update 2: The problem seen in your screenshot is most likely a bug in the GTK+ theme. Around half of the themes I tested (both with GTK+ 2 and 3) have this problem. For the record, my screenshot was taken with the Adwaita (GTK+ 3) theme.

Upvotes: 2

Related Questions