[pygtk] how to change value in slider
Sibtey Mehdi
sibteym at chetu.com
Tue Apr 7 00:38:36 WST 2009
Thanks Neil , it is working well
-----Original Message-----
From: pygtk-bounces at daa.com.au on behalf of Neil Muller
Sent: Sat 4/4/2009 4:14 PM
To: pygtk at daa.com.au
Subject: Re: [pygtk] how to change value in slider
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?
_______________________________________________
pygtk mailing list pygtk at daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20090406/afb24ebd/attachment.htm
More information about the pygtk
mailing list