In the docs for wx.Slider
(wxPython for py2, wxPython for py3, wxWidgets), there is listed a widget control named wx.SL_SELRANGE
, defined to allow "the user to select a range on the slider (MSW only)". To me, this speaks of a twin-control, two sliders on the same axis in order to define a low/high range. I can't get it to show two controls.
Basic code to get it started. I'm not even worried yet about methods, events, or whatnot at this point, just to show something.
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
# ... sizers and other stuff
self.myslider = wx.Slider(self.notebook_1_pane_2, wx.ID_ANY, 0, -100, 100, style=wx.SL_SELRANGE)
# ...
self.myslider.SetSelection(10, 90)
With all of that, the most I've been able to get it to show is a blue line spanning about where I would expect things to be.
The wxPython docs all talk about it but how is the user supposed to be able to "select a range on the slider", like shown here (taken from shiny
)?
What am I missing? Are there any reasonable public examples of a wxPython wx.Slider
in the wild with this functionality?
PS:
- One page I found speaks of WinXP only, but since that page hasn't been updated in seven years, I don't consider it authoritative on the version restriction.
- I've been using wxGlade for gui layout, but I'm certainly willing/able to go into the code after export and muck around.
System: win81_64, python-2.7.10, wxPython-3.0.2.0
I have made a custom implementation for this, partly using a code from this question. Left click on the slider area sets the left border of the range, right click sets the right border. Dragging the slider moves the selection.
left_gap
andright_gap
indicates what is the empty space between edges of the widget and actual start of the drawn slider. As in the source, these must be found out by experimentation.