Table Of Contents

Previous topic

SpinButton

Next topic

SpinCtrlDouble

This Page

phoenix_title SpinCtrl

SpinCtrl combines TextCtrl and SpinButton in one control.

styles Window Styles

This class supports the following styles:

  • SP_ARROW_KEYS: The user can use arrow keys to change the value.
  • SP_WRAP: The value wraps at the minimum and maximum.
  • TE_PROCESS_ENTER: Indicates that the control should generate wxEVT_COMMAND_TEXT_ENTER events. Using this style will prevent the user from using the Enter key for dialog navigation (e.g. activating the default button in the dialog) under MSW.
  • ALIGN_LEFT: Same as TE_LEFT for TextCtrl: the text is left aligned.
  • ALIGN_CENTRE: Same as TE_CENTRE for TextCtrl: the text is centered.
  • ALIGN_RIGHT: Same as TE_RIGHT for TextCtrl: the text is right aligned (this is the default).

events Events Emitted by this Class

Handlers bound for the following event types will receive a SpinEvent parameter.

  • EVT_SPINCTRL: Process a wxEVT_COMMAND_SPINCTRL_UPDATED event, which is generated whenever the numeric value of the spin control is updated.

You may also use the SpinButton event macros, however the corresponding events will not be generated under all platforms. Finally, if the user modifies the text in the edit part of the spin control directly, the EVT_TEXT is generated, like for the TextCtrl. When the use enters text into the text area, the text is not validated until the control loses focus (e.g. by using the TAB key). The value is then adjusted to the range and a SpinEvent sent then if the value is different from the last value sent.


class_hierarchy Inheritance Diagram

Inheritance diagram for class SpinCtrl

Inheritance diagram of SpinCtrl


appearance Control Appearance


wxMSW

wxMSW

wxMAC

wxMAC

wxGTK

wxGTK


method_summary Methods Summary

__init__ Default constructor.
Create Creation function called by the spin control constructor.
GetMax Gets maximal allowable value.
GetMin Gets minimal allowable value.
GetRange  
GetValue Gets the value of the spin control.
SetMax  
SetMin  
SetRange Sets range of allowable values.
SetSelection Select the text in the text part of the control between positions from (inclusive) and to (exclusive).
SetValue Sets the value of the spin control.

property_summary Properties Summary

Max See GetMax and SetMax
Min See GetMin and SetMin
Range See GetRange
Value See GetValue and SetValue

api Class API



class SpinCtrl(Control)

SpinCtrl combines TextCtrl and SpinButton in one control.

Possible constructors:

SpinCtrl()

SpinCtrl(parent, id=ID_ANY, value='', pos=DefaultPosition,
         size=DefaultSize, style=SP_ARROW_KEYS, min=0, max=100, initial=0,
         name="wxSpinCtrl")

Methods



__init__(self, *args, **kw)

overload Overloaded Implementations:



__init__ (self)

Default constructor.



__init__ (self, parent, id=ID_ANY, value=’‘, pos=DefaultPosition, size=DefaultSize, style=SP_ARROW_KEYS, min=0, max=100, initial=0, name=”wxSpinCtrl”)

Constructor, creating and showing a spin control.

If value is non-empty, it will be shown in the text entry part of the control and if it has numeric value, the initial numeric value of the control, as returned by GetValue will also be determined by it instead of by initial. Hence, it only makes sense to specify initial if value is an empty string or is not convertible to a number, otherwise initial is simply ignored and the number specified by value is used.

Parameters:
  • parent (Window) – Parent window. Must not be None.
  • id (int) – Window identifier. The value ID_ANY indicates a default value.
  • value (string) – Default value (as text).
  • pos (Point) – Window position. If DefaultPosition is specified then a default position is chosen.
  • size (Size) – Window size. If DefaultSize is specified then a default size is chosen.
  • style (long) – Window style. See SpinButton.
  • min (int) – Minimal value.
  • max (int) – Maximal value.
  • initial (int) – Initial value.
  • name (string) – Window name.

See also

Create





Create(self, parent, id=ID_ANY, value='', pos=DefaultPosition, size=DefaultSize, style=SP_ARROW_KEYS, min=0, max=100, initial=0, name="wxSpinCtrl")

Creation function called by the spin control constructor.

See SpinCtrl for details.

Parameters:
  • parent (Window) –
  • id (int) –
  • value (string) –
  • pos (Point) –
  • size (Size) –
  • style (long) –
  • min (int) –
  • max (int) –
  • initial (int) –
  • name (string) –
Return type:

bool



GetMax(self)

Gets maximal allowable value.

Return type:int


GetMin(self)

Gets minimal allowable value.

Return type:int


GetRange(self)


GetValue(self)

Gets the value of the spin control.

Return type:int


SetMax(self, maxVal)


SetMin(self, minVal)


SetRange(self, minVal, maxVal)

Sets range of allowable values.

Parameters:
  • minVal (int) –
  • maxVal (int) –


SetSelection(self, from_, to_)

Select the text in the text part of the control between positions from (inclusive) and to (exclusive).

This is similar to TextCtrl.SetSelection .

Parameters:
  • from_ (long) –
  • to_ (long) –

Note

this is currently only implemented for Windows and generic versions of the control.



SetValue(self, *args, **kw)

overload Overloaded Implementations:



SetValue (self, text)

Sets the value of the spin control.

Use the variant using int instead.

Parameters:text (string) –



SetValue (self, value)

Sets the value of the spin control.

Parameters:value (int) –




Properties



Max

See GetMax and SetMax



Min

See GetMin and SetMin



Range

See GetRange



Value

See GetValue and SetValue