.. include:: headings.inc .. _Slider: ========================================================================================================================================== |phoenix_title| **Slider** ========================================================================================================================================== A slider is a control with a handle which can be pulled back and forth to change the value. On Windows, the track bar control is used. Slider events are handled in the same way as a scrollbar. .. _Slider-styles: |styles| Window Styles ================================ This class supports the following styles: - ``SL_HORIZONTAL``: Displays the slider horizontally (this is the default). - ``SL_VERTICAL``: Displays the slider vertically. - ``SL_AUTOTICKS``: Displays tick marks. Windows only. - ``SL_MIN_MAX_LABELS``: Displays minimum, maximum labels (new since wxWidgets 2.9.1). - ``SL_VALUE_LABEL``: Displays value label (new since wxWidgets 2.9.1). - ``SL_LABELS``: Displays minimum, maximum and value labels (same as ``SL_VALUE_LABEL`` and ``SL_MIN_MAX_LABELS`` together). - ``SL_LEFT``: Displays ticks on the left and forces the slider to be vertical. - ``SL_RIGHT``: Displays ticks on the right and forces the slider to be vertical. - ``SL_TOP``: Displays ticks on the top. - ``SL_BOTTOM``: Displays ticks on the bottom (this is the default). - ``SL_SELRANGE``: Allows the user to select a range on the slider. Windows only. - ``SL_INVERSE``: Inverses the minimum and maximum endpoints on the slider. Not compatible with ``SL_SELRANGE``. Notice that ``SL_LEFT`` , ``SL_TOP`` , ``SL_RIGHT`` and ``SL_BOTTOM`` specify the position of the slider ticks in MSW implementation and that the slider labels, if any, are positioned on the opposite side. So, to have a label on the left side of a vertical slider, **``SL_RIGHT``** must be used (or none of these styles at all should be specified as left and top are default positions for the vertical and horizontal sliders respectively). .. _Slider-events: |events| Events Emitted by this Class ===================================== Handlers bound for the following event types will receive a :ref:`ScrollEvent` parameter. - EVT_SCROLL: Process all scroll events. - EVT_SCROLL_TOP: Process ``wxEVT_SCROLL_TOP`` scroll-to-top events (minimum position). - EVT_SCROLL_BOTTOM: Process ``wxEVT_SCROLL_BOTTOM`` scroll-to-bottom events (maximum position). - EVT_SCROLL_LINEUP: Process ``wxEVT_SCROLL_LINEUP`` line up events. - EVT_SCROLL_LINEDOWN: Process ``wxEVT_SCROLL_LINEDOWN`` line down events. - EVT_SCROLL_PAGEUP: Process ``wxEVT_SCROLL_PAGEUP`` page up events. - EVT_SCROLL_PAGEDOWN: Process ``wxEVT_SCROLL_PAGEDOWN`` page down events. - EVT_SCROLL_THUMBTRACK: Process ``wxEVT_SCROLL_THUMBTRACK`` thumbtrack events (frequent events sent as the user drags the thumbtrack). - EVT_SCROLL_THUMBRELEASE: Process ``wxEVT_SCROLL_THUMBRELEASE`` thumb release events. - EVT_SCROLL_CHANGED: Process ``wxEVT_SCROLL_CHANGED`` end of scrolling events (MSW only). - EVT_COMMAND_SCROLL: Process all scroll events. - EVT_COMMAND_SCROLL_TOP: Process ``wxEVT_SCROLL_TOP`` scroll-to-top events (minimum position). - EVT_COMMAND_SCROLL_BOTTOM: Process ``wxEVT_SCROLL_BOTTOM`` scroll-to-bottom events (maximum position). - EVT_COMMAND_SCROLL_LINEUP: Process ``wxEVT_SCROLL_LINEUP`` line up events. - EVT_COMMAND_SCROLL_LINEDOWN: Process ``wxEVT_SCROLL_LINEDOWN`` line down events. - EVT_COMMAND_SCROLL_PAGEUP: Process ``wxEVT_SCROLL_PAGEUP`` page up events. - EVT_COMMAND_SCROLL_PAGEDOWN: Process ``wxEVT_SCROLL_PAGEDOWN`` page down events. - EVT_COMMAND_SCROLL_THUMBTRACK: Process ``wxEVT_SCROLL_THUMBTRACK`` thumbtrack events (frequent events sent as the user drags the thumbtrack). - EVT_COMMAND_SCROLL_THUMBRELEASE: Process ``wxEVT_SCROLL_THUMBRELEASE`` thumb release events. - EVT_COMMAND_SCROLL_CHANGED: Process ``wxEVT_SCROLL_CHANGED`` end of scrolling events (MSW only). - EVT_SLIDER: Process ``wxEVT_COMMAND_SLIDER_UPDATED`` which is generated after any change of :ref:`Slider` position in addition to one of the events above. |phoenix_title| The difference between ``EVT_SCROLL_THUMBRELEASE`` and ``EVT_SCROLL_CHANGED`` ============================================================================================= The ``EVT_SCROLL_THUMBRELEASE`` event is only emitted when actually dragging the thumb using the mouse and releasing it (This ``EVT_SCROLL_THUMBRELEASE`` event is also followed by an ``EVT_SCROLL_CHANGED`` event). The ``EVT_SCROLL_CHANGED`` event also occurs when using the keyboard to change the thumb position, and when clicking next to the thumb (In all these cases the ``EVT_SCROLL_THUMBRELEASE`` event does not happen). In short, the ``EVT_SCROLL_CHANGED`` event is triggered when scrolling/ moving has finished independently of the way it had started. Please see the widgets sample ("Slider" page) to see the difference between ``EVT_SCROLL_THUMBRELEASE`` and ``EVT_SCROLL_CHANGED`` in action. .. seealso:: :ref:`Events and Event Handling `, :ref:`ScrollBar` | |class_hierarchy| Inheritance Diagram ===================================== Inheritance diagram for class **Slider** .. raw:: html

Inheritance diagram of Slider

| |appearance| Control Appearance =============================== | .. figure:: _static/images/widgets/fullsize/wxmsw/slider.png :alt: wxMSW :figclass: floatleft **wxMSW** .. figure:: _static/images/widgets/fullsize/wxmac/slider.png :alt: wxMAC :figclass: floatright **wxMAC** .. figure:: _static/images/widgets/fullsize/wxgtk/slider.png :alt: wxGTK :figclass: floatcenter **wxGTK** | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~Slider.__init__` Default constructor. :meth:`~Slider.ClearSel` Clears the selection, for a slider with the **``SL_SELRANGE``** style. :meth:`~Slider.ClearTicks` Clears the ticks. :meth:`~Slider.Create` Used for two-step slider construction. :meth:`~Slider.GetLineSize` Returns the line size. :meth:`~Slider.GetMax` Gets the maximum slider value. :meth:`~Slider.GetMin` Gets the minimum slider value. :meth:`~Slider.GetPageSize` Returns the page size. :meth:`~Slider.GetRange` :meth:`~Slider.GetSelEnd` Returns the selection end point. :meth:`~Slider.GetSelStart` Returns the selection start point. :meth:`~Slider.GetThumbLength` Returns the thumb length. :meth:`~Slider.GetTickFreq` Returns the tick frequency. :meth:`~Slider.GetValue` Gets the current slider value. :meth:`~Slider.SetLineSize` Sets the line size for the slider. :meth:`~Slider.SetPageSize` Sets the page size for the slider. :meth:`~Slider.SetRange` Sets the minimum and maximum slider values. :meth:`~Slider.SetSelection` Sets the selection. :meth:`~Slider.SetThumbLength` Sets the slider thumb length. :meth:`~Slider.SetTick` Sets a tick position. :meth:`~Slider.SetTickFreq` Sets the tick mark frequency and position. :meth:`~Slider.SetValue` Sets the slider position. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~Slider.LineSize` See :meth:`~Slider.GetLineSize` and :meth:`~Slider.SetLineSize` :attr:`~Slider.Max` See :meth:`~Slider.GetMax` :attr:`~Slider.Min` See :meth:`~Slider.GetMin` :attr:`~Slider.PageSize` See :meth:`~Slider.GetPageSize` and :meth:`~Slider.SetPageSize` :attr:`~Slider.Range` See :meth:`~Slider.GetRange` :attr:`~Slider.SelEnd` See :meth:`~Slider.GetSelEnd` :attr:`~Slider.SelStart` See :meth:`~Slider.GetSelStart` :attr:`~Slider.ThumbLength` See :meth:`~Slider.GetThumbLength` and :meth:`~Slider.SetThumbLength` :attr:`~Slider.TickFreq` See :meth:`~Slider.GetTickFreq` and :meth:`~Slider.SetTickFreq` :attr:`~Slider.Value` See :meth:`~Slider.GetValue` and :meth:`~Slider.SetValue` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: Slider(Control) A slider is a control with a handle which can be pulled back and forth to change the value. **Possible constructors**:: Slider() Slider(parent, id=ID_ANY, value=0, minValue=0, maxValue=100, pos=DefaultPosition, size=DefaultSize, style=SL_HORIZONTAL, validator=DefaultValidator, name=SliderNameStr) .. method:: __init__(self, *args, **kw) |overload| **Overloaded Implementations**: **~~~** **__init__** `(self)` Default constructor. **~~~** **__init__** `(self, parent, id=ID_ANY, value=0, minValue=0, maxValue=100, pos=DefaultPosition, size=DefaultSize, style=SL_HORIZONTAL, validator=DefaultValidator, name=SliderNameStr)` Constructor, creating and showing a slider. :param `parent`: Parent window. Must not be ``None``. :type `parent`: Window :param `id`: Window identifier. The value ``ID_ANY`` indicates a default value. :type `id`: int :param `value`: Initial position for the slider. :type `value`: int :param `minValue`: Minimum slider position. :type `minValue`: int :param `maxValue`: Maximum slider position. :type `maxValue`: int :param `pos`: Window position. If ``DefaultPosition`` is specified then a default position is chosen. :type `pos`: Point :param `size`: Window size. If ``DefaultSize`` is specified then a default size is chosen. :type `size`: Size :param `style`: Window style. See :ref:`Slider`. :type `style`: long :param `validator`: Window validator. :type `validator`: Validator :param `name`: Window name. :type `name`: string .. seealso:: :meth:`Create` , :ref:`Validator` **~~~** .. method:: ClearSel(self) Clears the selection, for a slider with the **``SL_SELRANGE``** style. .. availability:: Only available for MSW. .. method:: ClearTicks(self) Clears the ticks. .. availability:: Only available for MSW. .. method:: Create(self, parent, id=ID_ANY, value=0, minValue=0, maxValue=100, point=DefaultPosition, size=DefaultSize, style=SL_HORIZONTAL, validator=DefaultValidator, name=SliderNameStr) Used for two-step slider construction. See :ref:`Slider` for further details. :param `parent`: :type `parent`: Window :param `id`: :type `id`: int :param `value`: :type `value`: int :param `minValue`: :type `minValue`: int :param `maxValue`: :type `maxValue`: int :param `point`: :type `point`: Point :param `size`: :type `size`: Size :param `style`: :type `style`: long :param `validator`: :type `validator`: Validator :param `name`: :type `name`: string :rtype: `bool` .. method:: GetLineSize(self) Returns the line size. :rtype: `int` .. seealso:: :meth:`SetLineSize` .. method:: GetMax(self) Gets the maximum slider value. :rtype: `int` .. seealso:: :meth:`GetMin` , :meth:`SetRange` .. method:: GetMin(self) Gets the minimum slider value. :rtype: `int` .. seealso:: :meth:`GetMin` , :meth:`SetRange` .. method:: GetPageSize(self) Returns the page size. :rtype: `int` .. seealso:: :meth:`SetPageSize` .. method:: GetRange(self) .. method:: GetSelEnd(self) Returns the selection end point. :rtype: `int` .. availability:: Only available for MSW. .. seealso:: :meth:`GetSelStart` , :meth:`SetSelection` .. method:: GetSelStart(self) Returns the selection start point. :rtype: `int` .. availability:: Only available for MSW. .. seealso:: :meth:`GetSelEnd` , :meth:`SetSelection` .. method:: GetThumbLength(self) Returns the thumb length. :rtype: `int` .. availability:: Only available for MSW. .. seealso:: :meth:`SetThumbLength` .. method:: GetTickFreq(self) Returns the tick frequency. :rtype: `int` .. availability:: Only available for MSW. .. seealso:: :meth:`SetTickFreq` .. method:: GetValue(self) Gets the current slider value. :rtype: `int` .. seealso:: :meth:`GetMin` , :meth:`GetMax` , :meth:`SetValue` .. method:: SetLineSize(self, lineSize) Sets the line size for the slider. :param `lineSize`: The number of steps the slider moves when the user moves it up or down a line. :type `lineSize`: int .. seealso:: :meth:`GetLineSize` .. method:: SetPageSize(self, pageSize) Sets the page size for the slider. :param `pageSize`: The number of steps the slider moves when the user pages up or down. :type `pageSize`: int .. seealso:: :meth:`GetPageSize` .. method:: SetRange(self, minValue, maxValue) Sets the minimum and maximum slider values. :param `minValue`: :type `minValue`: int :param `maxValue`: :type `maxValue`: int .. seealso:: :meth:`GetMin` , :meth:`GetMax` .. method:: SetSelection(self, startPos, endPos) Sets the selection. :param `startPos`: The selection start position. :type `startPos`: int :param `endPos`: The selection end position. :type `endPos`: int MSW port. .. availability:: Only available for MSW. .. seealso:: :meth:`GetSelStart` , :meth:`GetSelEnd` .. method:: SetThumbLength(self, len) Sets the slider thumb length. :param `len`: The thumb length. :type `len`: int MSW port. .. availability:: Only available for MSW. .. seealso:: :meth:`GetThumbLength` .. method:: SetTick(self, tickPos) Sets a tick position. :param `tickPos`: The tick position. :type `tickPos`: int MSW port. .. availability:: Only available for MSW. .. seealso:: :meth:`SetTickFreq` .. method:: SetTickFreq(self, n) Sets the tick mark frequency and position. :param `n`: Frequency. For example, if the frequency is set to two, a tick mark is displayed for every other increment in the slider's range. :type `n`: int MSW port. .. availability:: Only available for MSW. .. seealso:: :meth:`GetTickFreq` .. method:: SetValue(self, value) Sets the slider position. :param `value`: The slider position. :type `value`: int .. attribute:: LineSize See :meth:`~Slider.GetLineSize` and :meth:`~Slider.SetLineSize` .. attribute:: Max See :meth:`~Slider.GetMax` .. attribute:: Min See :meth:`~Slider.GetMin` .. attribute:: PageSize See :meth:`~Slider.GetPageSize` and :meth:`~Slider.SetPageSize` .. attribute:: Range See :meth:`~Slider.GetRange` .. attribute:: SelEnd See :meth:`~Slider.GetSelEnd` .. attribute:: SelStart See :meth:`~Slider.GetSelStart` .. attribute:: ThumbLength See :meth:`~Slider.GetThumbLength` and :meth:`~Slider.SetThumbLength` .. attribute:: TickFreq See :meth:`~Slider.GetTickFreq` and :meth:`~Slider.SetTickFreq` .. attribute:: Value See :meth:`~Slider.GetValue` and :meth:`~Slider.SetValue`