Page 1 of 1

wxSlider with two thumbs

Posted: Tue Mar 13, 2018 5:48 pm
by mael15
hi,
is there such a thing as a wxSlider with two thumbs? i want to enable the user to set a range between two extreme int values. i.e. minimum = 10 and maximum = 1000, the user can set a range from 247 to 830.
can i create a slider with two thumbs?
maybe there is a better way?
thank you!

Re: wxSlider with two thumbs

Posted: Tue Mar 13, 2018 5:56 pm
by doublemax
Only supported under MSW, check the wxSL_SELRANGE style for wxSlider.

Re: wxSlider with two thumbs

Posted: Tue Mar 13, 2018 9:36 pm
by eranon
Hello, Outside of MSW, a kind of workaround there: https://stackoverflow.com/questions/297 ... e-on-linux

Where jordan9001 says:
You could have two sliders; one that will push the other so it remains lower, and one will remain higher?

I know it isn't the same thing, sorry, but it is an option. So when ever self.minSlider is moved, you bind wx.EVT_SCROLL with a function that will do something like:

Code: Select all

self.minSlider.Bind(wx.EVT_SCROLL, self.respondSliderChange())

def respondSliderChange(self):
    if self.minSlider.GetValue() >= self.maxSlider.GetValue():
        self.maxSlider.SetValue(self.minSlider.GetValue()+1)
and vice-versa for the maxSlider.

Besides that, you can look into creating a custom widget here.

Re: wxSlider with two thumbs

Posted: Sun Mar 25, 2018 8:37 am
by mael15
doublemax wrote:Only supported under MSW, check the wxSL_SELRANGE style for wxSlider.
That seems perfect because my program is windows only. But the only change I see is a thicker slider bar?! No second thumb, so how can this select a range?!

Re: wxSlider with two thumbs

Posted: Sun Mar 25, 2018 9:30 am
by doublemax
Sorry for putting you on the wrong track. After reading up on it, it turns out that this only enables you to display a visible range in the slider. But this can't be controlled by the user directly.

Re: wxSlider with two thumbs

Posted: Mon Mar 26, 2018 2:39 pm
by ONEEYEMAN
Hi,
Why do you need 2 thumbs?
As a workaround you could try to have 2 slider controls - 1 for a minimum value and 1 for maximum value. This will be much better UI/UX than having 2 thumbs which will confuse people.

Thank you.

Re: wxSlider with two thumbs

Posted: Tue Mar 27, 2018 8:51 am
by mael15
I want to enable the user to limit minimum and maximum for x and y coordinates, so I am using four sliders at the moment. These use a lot of space, I want to use as few controls as possible, and I think a two thumb slider would be very intuitive (at least for the x values with a horizontal slider).
left slider always stays at least one tick left of the right slider, the values are shows left and right beside the slider. I guess I will have to build a custom one.

Re: wxSlider with two thumbs

Posted: Tue Mar 27, 2018 8:00 pm
by eranon
In last resort, you could manage a double-thumb slider in a wxWebView (e.g. http://jsfiddle.net/abhitalks/a1f1k8d0/2/ and a lot of ways around searching on keywords like "javascript slider two thumbs") then acquire back the values at every change... But, of course, it's a little convoluted :wink:

Re: wxSlider with two thumbs

Posted: Wed Mar 28, 2018 8:25 am
by mael15
eranon wrote:In last resort, you could manage a double-thumb slider in a wxWebView (e.g. http://jsfiddle.net/abhitalks/a1f1k8d0/2/ and a lot of ways around searching on keywords like "javascript slider two thumbs") then acquire back the values at every change... But, of course, it's a little convoluted :wink:
interesting, thank you.
i am in the process of creating my own control. i have some classes using wxDragBitmap already, so it should work using these. unfortunately it seemed unpractical to inherit from wxSlider because it seems to be only a shell (is this the correct word?!) for os specific controls. i did not see an easy way to add a second thumb there.
if anyone needs the same thing and would like to have my source code, just send me a message or post here.
thanx everyone for your input!

Re: wxSlider with two thumbs

Posted: Wed Mar 28, 2018 8:41 am
by eranon
mael15 wrote:unfortunately it seemed unpractical to inherit from wxSlider because it seems to be only a shell (is this the correct word?!) for os specific controls. i did not see an easy way to add a second thumb there.
It's not an issue, it's a feature! It's one of the top quality of wxWidgets to rely on native controls... So, of course, by design, most of the time (unless when it's already possible with the OS's API itself), you can't change the native behavior of the controls.

Re: wxSlider with two thumbs

Posted: Thu May 17, 2018 3:13 am
by ggbutcher
I wrote one to implement a black/white point setter for an image processing program. You can find it here:

https://github.com/butcherg/rawproc/blob/master/src/

Look for myDoubleSlider.cpp, my DoubleSlider.h