[pygtk] scaling in slider
A.T.Hofkamp
a.t.hofkamp at tue.nl
Tue Mar 24 20:37:18 WST 2009
Sibtey Mehdi wrote:
> Hi all
> i am newbie to pygtk i am trying to add the slider in my application. i want the increment shuold be like
> 2,4,8,16, 32,64.how can i do this. i am doing by this way but it is not working fine.
> x = 1
> adj = gtk.Adjustment(1,1, 64, 2, 2, 0)
> hscale = gtk.HScale(adj)
> hscale.connect("value_changed", cb_digits_scale)
>
> def cb_digits_scale(hscale):
> x = adj.get_value()
> value = x*2
> adj.set_value(value)
>
> can anyone suggest me?
Last year I tried to implement a logarithmic scale too, and succeeded partly.
I used a linear scale for the widget (in your case 1 .. 6), and use that value
internally.
To get the desired output to the user of the value, I used a conversion
function (in your case 2 << value).
What breaks here is that there seems no way to get the slider display the
logarithmic scale rather than the linear one.
I 'fixed' this by not displaying a number at all.
Sincerely,
Albert
More information about the pygtk
mailing list