wx.Slider: Increment slider steps by 0.1

101 views
Skip to first unread message

austin aigbe

unread,
Feb 14, 2016, 7:20:28 PM2/14/16
to wxPython-users
Hello,

"       h2 = wx.BoxSizer(wx.HORIZONTAL)
        green = wx.StaticText(gamma_table, label="Green")
        h2.Add(green, 0, wx.ALL)
        scale_gamma_green = wx.Slider(gamma_table, -1, 2.2, 0.1, 3.0, style=wx.SL_HORIZONTAL|wx.SL_VALUE_LABEL|wx.SL_BOTTOM)
        scale_gamma_green.SetLineSize(0.1)
        h2.Add(scale_gamma_green, 1, wx.ALL,2)
"

Slider increments by 1 instead of 0.1.

How do I get the slider to increment in steps of 0.1? Thanks.

Regards,
Austin

Tim Roberts

unread,
Feb 15, 2016, 1:27:59 PM2/15/16
to wxpytho...@googlegroups.com
The Slider control only works with integers. You will have to do the
scaling yourself when you fetch and set the values. Multiply the values
here by 10, and divide by 10 when you read the current value.

--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

rzzzwilson

unread,
Feb 15, 2016, 8:52:17 PM2/15/16
to wxPython-users
I faced this problem a while back.  My solution is probably more than you need, but example code with a simple test is at https://github.com/rzzzwilson/Random-Stuff/tree/master/float_slider.

austin aigbe

unread,
Feb 16, 2016, 5:09:37 PM2/16/16
to wxpytho...@googlegroups.com
Exactly what I need. Thanks.

On Tue, Feb 16, 2016 at 2:52 AM, rzzzwilson <rzzzw...@gmail.com> wrote:
I faced this problem a while back.  My solution is probably more than you need, but example code with a simple test is at https://github.com/rzzzwilson/Random-Stuff/tree/master/float_slider.

--
You received this message because you are subscribed to a topic in the Google Groups "wxPython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wxpython-users/FwYHYz9BO2g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages