.. include:: headings.inc .. _SpinButton: ========================================================================================================================================== |phoenix_title| **SpinButton** ========================================================================================================================================== A :ref:`SpinButton` has two small up and down (or left and right) arrow buttons. It is often used next to a text control for increment and decrementing a value. Portable programs should try to use :ref:`SpinCtrl` instead as :ref:`SpinButton` is not implemented for all platforms but :ref:`SpinCtrl` is as it degenerates to a simple :ref:`TextCtrl` on such platforms. .. _SpinButton-styles: |styles| Window Styles ================================ This class supports the following styles: - ``SP_HORIZONTAL``: Specifies a horizontal spin button (note that this style is not supported in wxGTK). - ``SP_VERTICAL``: Specifies a vertical spin button. - ``SP_ARROW_KEYS``: The user can use arrow keys to change the value. - ``SP_WRAP``: The value wraps at the minimum and maximum. .. _SpinButton-events: |events| Events Emitted by this Class ===================================== Handlers bound for the following event types will receive a :ref:`SpinEvent` parameter. - EVT_SPIN: Generated whenever an arrow is pressed. - EVT_SPIN_UP: Generated when left/up arrow is pressed. - EVT_SPIN_DOWN: Generated when right/down arrow is pressed. Note that if you handle both ``SPIN`` and ``UP`` or ``DOWN`` events, you will be notified about each of them twice: first the UP/DOWN event will be received and then, if it wasn't vetoed, the ``SPIN`` event will be sent. .. note:: the range supported by this control (and :ref:`SpinCtrl`) depends on the platform but is at least ``-0x8000`` to ``0x7fff`` . Under GTK and Win32 with sufficiently new version of ``comctrl32.dll`` (at least 4.71 is required, 5.80 is recommended) the full 32 bit range is supported. .. seealso:: :ref:`SpinCtrl` | |class_hierarchy| Inheritance Diagram ===================================== Inheritance diagram for class **SpinButton** .. raw:: html

Inheritance diagram of SpinButton

| |appearance| Control Appearance =============================== | .. figure:: _static/images/widgets/fullsize/wxmsw/spinbutton.png :alt: wxMSW :figclass: floatleft **wxMSW** .. figure:: _static/images/widgets/fullsize/wxmac/spinbutton.png :alt: wxMAC :figclass: floatright **wxMAC** .. figure:: _static/images/widgets/fullsize/wxgtk/spinbutton.png :alt: wxGTK :figclass: floatcenter **wxGTK** | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~SpinButton.__init__` Default constructor. :meth:`~SpinButton.Create` Scrollbar creation function called by the spin button constructor. :meth:`~SpinButton.GetMax` Returns the maximum permissible value. :meth:`~SpinButton.GetMin` Returns the minimum permissible value. :meth:`~SpinButton.GetRange` :meth:`~SpinButton.GetValue` Returns the current spin button value. :meth:`~SpinButton.SetMax` :meth:`~SpinButton.SetMin` :meth:`~SpinButton.SetRange` Sets the range of the spin button. :meth:`~SpinButton.SetValue` Sets the value of the spin button. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~SpinButton.Max` See :meth:`~SpinButton.GetMax` and :meth:`~SpinButton.SetMax` :attr:`~SpinButton.Min` See :meth:`~SpinButton.GetMin` and :meth:`~SpinButton.SetMin` :attr:`~SpinButton.Range` See :meth:`~SpinButton.GetRange` :attr:`~SpinButton.Value` See :meth:`~SpinButton.GetValue` and :meth:`~SpinButton.SetValue` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: SpinButton(Control) A SpinButton has two small up and down (or left and right) arrow buttons. **Possible constructors**:: SpinButton() SpinButton(parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=SP_VERTICAL, name="spinButton") .. method:: __init__(self, *args, **kw) |overload| **Overloaded Implementations**: **~~~** **__init__** `(self)` Default constructor. **~~~** **__init__** `(self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=SP_VERTICAL, name="spinButton")` Constructor, creating and showing a spin button. :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 `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:`SpinButton` class description. :type `style`: long :param `name`: Window name. :type `name`: string .. seealso:: :meth:`Create` **~~~** .. method:: Create(self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=SP_VERTICAL, name="wxSpinButton") Scrollbar creation function called by the spin button constructor. See :ref:`SpinButton` for details. :param `parent`: :type `parent`: Window :param `id`: :type `id`: int :param `pos`: :type `pos`: Point :param `size`: :type `size`: Size :param `style`: :type `style`: long :param `name`: :type `name`: string :rtype: `bool` .. method:: GetMax(self) Returns the maximum permissible value. :rtype: `int` .. seealso:: :meth:`SetRange` .. method:: GetMin(self) Returns the minimum permissible value. :rtype: `int` .. seealso:: :meth:`SetRange` .. method:: GetRange(self) .. method:: GetValue(self) Returns the current spin button value. :rtype: `int` .. seealso:: :meth:`SetValue` .. method:: SetMax(self, maxVal) .. method:: SetMin(self, minVal) .. method:: SetRange(self, min, max) Sets the range of the spin button. :param `min`: The minimum value for the spin button. :type `min`: int :param `max`: The maximum value for the spin button. :type `max`: int .. seealso:: :meth:`GetMin` , :meth:`GetMax` .. method:: SetValue(self, value) Sets the value of the spin button. :param `value`: The value for the spin button. :type `value`: int .. attribute:: Max See :meth:`~SpinButton.GetMax` and :meth:`~SpinButton.SetMax` .. attribute:: Min See :meth:`~SpinButton.GetMin` and :meth:`~SpinButton.SetMin` .. attribute:: Range See :meth:`~SpinButton.GetRange` .. attribute:: Value See :meth:`~SpinButton.GetValue` and :meth:`~SpinButton.SetValue`