[pygtk] how to change value in slider
Neil Muller
drnlmuller+gtk at gmail.com
Sat Apr 4 18:44:31 WST 2009
On Fri, Apr 3, 2009 at 7:54 PM, Sibtey Mehdi <sibteym at chetu.com> wrote:
>
> hi
> I am trying to change the value in the slider bar but it is allowing
> to change the value within the range given in the
> adjustment. if the current values are 1,2,4,5,6,7 then i want slider
> should show 1,2,4,8,16,32,64.how can i do this any one can help me out this
> problem? even the set_value(newvalue) function changes values within the
> lower and upper values but that changes are also not displayed on the
> slider.
Why not hook onto the format_value signal?
Something like:
class Scale(object):
"""A scale that adheres to increment steps"""
def __init__(self,x):
self.set_update_policy(gtk.UPDATE_CONTINUOUS)
self.set_size_request(150,35)
self.connect("format-value", self.display_value)
def display_value(self, widget, value):
return "%d" % 2**(value-1)
(You'll probably also want to override get_value so you get the
displayed value out of the widget.)
--
Neil Muller
drnlmuller at gmail.com
I've got a gmail account. Why haven't I become cool?
More information about the pygtk
mailing list