Scroll wheel motion and sliders

Eric Fahlgren <[email protected]> Tue, 19 Feb 2019 16:15:01 -0800
Newsgroups gmane.comp.python.wxpython.devel
Message-ID <CAP2Qz+VzJ4XAvCS3JHNQuFDpj4UOMf3w9qiK0TAG+8vs0xb6FQ@mail.gmail.com>
We got a bug report that the sliders in our application were working
"backwards" when actuated with the scroll wheel.

On a vertical slider, scrolling the wheel "down" (towards yourself over the
top) always moves the slider down on the screen.  Using wx.SL_INVERSE style
on the widget puts the small value on the bottom and all is well with the
world.

With horizontal sliders though, scrolling down always moves the slider to
the right.  If you use ws.SL_INVERSE in this case, the small value on the
right is just too weirdly counter intuitive, so I'm not going there.  Is
there some way to intercept the scroll events and invert them for
horizontal sliders so "down" goes left?  (We found some horizontal sliders
in PowerPoint and they behave this way, so even Microsoft thinks this is
correct.)

Thanks,
Eric

Obligatory test script:

#!/usr/bin/env python

import wx

class SliderFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "Slider Example", size=(600, 350))
        panel = wx.Panel(self)
        s1 = wx.Slider(panel, pos=(  0, 0),
size=(300,300),style=wx.SL_HORIZONTAL | wx.SL_LABELS)
        s2 = wx.Slider(panel, pos=(300, 0),
size=(300,300),style=wx.SL_VERTICAL   | wx.SL_LABELS | wx.SL_INVERSE)
        s1.Bind(wx.EVT_SCROLL_CHANGED, self.OnScroll)
        s2.Bind(wx.EVT_SCROLL_CHANGED, self.OnScroll)

    def OnScroll(self, event):
        print(event.EventObject.GetValue())

if __name__ == "__main__":
    app = wx.App()
    frame = SliderFrame()
    frame.Show()
    app.MainLoop()

-- 
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.