.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2020 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc

.. currentmodule:: wx.lib.intctrl

.. highlight:: python



.. _wx.lib.intctrl.IntCtrl:

==========================================================================================================================================
|phoenix_title|  **wx.lib.intctrl.IntCtrl**
==========================================================================================================================================

This class provides a control that takes and returns integers as
value, and provides bounds support and optional value limiting.



|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>IntCtrl</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.lib.intctrl.IntCtrl_inheritance.png" alt="Inheritance diagram of IntCtrl" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.lib.intctrl.IntCtrl.html" title="wx.lib.intctrl.IntCtrl" alt="" coords="97,469,243,499"/> <area shape="rect" id="node2" href="wx.TextCtrl.html" title="wx.TextCtrl" alt="" coords="123,392,217,421"/> <area shape="rect" id="node3" href="wx.Control.html" title="wx.Control" alt="" coords="63,315,155,344"/> <area shape="rect" id="node4" href="wx.TextEntry.html" title="wx.TextEntry" alt="" coords="179,315,286,344"/> <area shape="rect" id="node5" href="wx.Window.html" title="wx.Window" alt="" coords="60,237,157,267"/> <area shape="rect" id="node6" href="wx.WindowBase.html" title="wx.WindowBase" alt="" coords="44,160,173,189"/> <area shape="rect" id="node7" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="50,83,167,112"/> <area shape="rect" id="node8" href="wx.Object.html" title="wx.Object" alt="" coords="5,5,92,35"/> <area shape="rect" id="node9" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="117,5,223,35"/> </map> 
   </p>
   </div>

|


|super_classes| Known Superclasses
==================================

:class:`wx.TextCtrl`

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.lib.intctrl.IntCtrl.__init__`                                         Default constructor
:meth:`~wx.lib.intctrl.IntCtrl.ChangeValue`                                      Change the value without sending an EVT_TEXT event.
:meth:`~wx.lib.intctrl.IntCtrl.Cut`                                              Override the :func:`TextCtrl.Cut` function, with our own
:meth:`~wx.lib.intctrl.IntCtrl.GetBounds`                                        This function returns a two-tuple (min,max), indicating the
:meth:`~wx.lib.intctrl.IntCtrl.GetColors`                                        Returns a tuple of (default_color, oob_color), indicating
:meth:`~wx.lib.intctrl.IntCtrl.GetMax`                                           Gets the maximum value of the control.  It will return the current
:meth:`~wx.lib.intctrl.IntCtrl.GetMin`                                           Gets the minimum value of the control.  It will return the current
:meth:`~wx.lib.intctrl.IntCtrl.GetValue`                                         Returns the current integer (long) value of the control.
:meth:`~wx.lib.intctrl.IntCtrl.IsInBounds`                                       Returns ``True`` if no value is specified and the current value
:meth:`~wx.lib.intctrl.IntCtrl.IsLimited`                                        Returns ``True`` if the control is currently limiting the
:meth:`~wx.lib.intctrl.IntCtrl.IsLongAllowed`                                    Is a long value allowed.
:meth:`~wx.lib.intctrl.IntCtrl.IsNoneAllowed`                                    Is a None value allowed.
:meth:`~wx.lib.intctrl.IntCtrl.OnText`                                           Handles an event indicating that the text control's value
:meth:`~wx.lib.intctrl.IntCtrl.Paste`                                            Override the :func:`TextCtrl.Paste` function, with our own
:meth:`~wx.lib.intctrl.IntCtrl.SetBounds`                                        This function is a convenience function for setting the min and max
:meth:`~wx.lib.intctrl.IntCtrl.SetColors`                                        Tells the control what colors to use for normal and out-of-bounds
:meth:`~wx.lib.intctrl.IntCtrl.SetLimited`                                       If called with a value of True, this function will cause the control
:meth:`~wx.lib.intctrl.IntCtrl.SetLongAllowed`                                   Change the behavior of the validation code, allowing control
:meth:`~wx.lib.intctrl.IntCtrl.SetMax`                                           Sets the maximum value of the control. If a value of None
:meth:`~wx.lib.intctrl.IntCtrl.SetMin`                                           Sets the minimum value of the control.  If a value of None
:meth:`~wx.lib.intctrl.IntCtrl.SetNoneAllowed`                                   Change the behavior of the validation code, allowing control
:meth:`~wx.lib.intctrl.IntCtrl.SetValue`                                         Sets the value of the control to the integer value specified.
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.lib.intctrl.IntCtrl.Limited`                                          Returns ``True`` if the control is currently limiting the
:attr:`~wx.lib.intctrl.IntCtrl.LongAllowed`                                      Is a long value allowed.
:attr:`~wx.lib.intctrl.IntCtrl.Max`                                              Gets the maximum value of the control.  It will return the current
:attr:`~wx.lib.intctrl.IntCtrl.Min`                                              Gets the minimum value of the control.  It will return the current
:attr:`~wx.lib.intctrl.IntCtrl.NoneAllowed`                                      Is a None value allowed.
:attr:`~wx.lib.intctrl.IntCtrl.Value`                                            Returns the current integer (long) value of the control.
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: IntCtrl(wx.TextCtrl)

   This class provides a control that takes and returns integers as
   value, and provides bounds support and optional value limiting.

   .. method:: __init__ ( self, parent, id=-1, value = 0, pos = wx.DefaultPosition, size = wx.DefaultSize, style = 0, validator = wx.DefaultValidator, name = "integer", min=None, max=None, limited = 0, allow_none = 0, allow_long = 0, default_color = wx.BLACK, oob_color = wx.RED, )

      Default constructor
      
      :param `parent`: parent window
      
      :param int `id`: window identifier. A value of -1 indicates a
        default value
      
      :param `value`: If no initial value is set, the default will be zero,
        or the minimum value, if specified.  If an illegal string is
        specified, a ValueError will result. (You can always later set the
        initial value with ChangeValue() after instantiation of the control.)
      
      :param tuple `pos`: the control position. A value of (-1, -1) indicates
        a default position, chosen by either the windowing system or
        wxPython, depending on platform
      
      :param wx.Size `size`: the control size. A value of (-1, -1) indicates a
        default size, chosen by either the windowing system or wxPython,
        depending on platform
      
      :param int `style`: the underlying :class:`TextCtrl` style
      
      :param wx.Validator `validator`: Normally None, IntCtrl uses its own
        validator to do value validation and input control.  However, a
        validator derived from :class:`~lib.intctrl.IntValidator` can be
        supplied to override the data transfer methods for the
        :class:`~lib.intctrl.IntValidator` class.
      
      :param int `min`: The minimum value that the control should allow.  This
        can be adjusted with SetMin().  If the control is not limited, any
        value below this bound will be colored with the current out-of-bounds
        color. If min < -sys.maxsize-1 and the control is configured to not
        allow long values, the minimum bound will still be set to the long
        value, but the implicit bound will be -sys.maxsize-1.
      
      :param int `max`: The maximum value that the control should allow.  This
        can be adjusted with SetMax().  If the control is not limited, any
        value above this bound will be colored with the current out-of-bounds
        color.  if max > sys.maxsize and the control is configured to not
        allow long values, the maximum bound will still be set to the long
        value, but the implicit bound will be sys.maxsize.
      
      :param bool `limited`: Boolean indicating whether the control
        prevents values from exceeding the currently set minimum and maximum
        values (bounds).  If ``False`` and bounds are set, out-of-bounds values
        will be colored with the current out-of-bounds color.
      
      :param bool `allow_none`: Boolean indicating whether or not the
        control is allowed to be empty, representing a value of None for the
        control.
      
      :param bool `allow_long`:  Boolean indicating whether or not the
        control is allowed to hold and return a long as well as an int.
      
      :param Color `default_color`:  Color value used for in-bounds values
        of the control.
      
      :param Color `oob_color`:  Color value used for out-of-bounds values
        of the control when the bounds are set but the control is not limited.


   .. method:: ChangeValue(self, value)

      Change the value without sending an EVT_TEXT event.
      
      :param int `value`: The value to be set


   .. method:: Cut( self )

      Override the :func:`TextCtrl.Cut` function, with our own
      that does validation.  Will result in a value of 0
      if entire contents of control are removed.


   .. method:: GetBounds(self)

      This function returns a two-tuple (min,max), indicating the
      current bounds of the control.  Each value can be None if
      that bound is not set.


   .. method:: GetColors(self)

      Returns a tuple of (default_color, oob_color), indicating
      the current color settings for the control.


   .. method:: GetMax(self)

      Gets the maximum value of the control.  It will return the current
      maximum integer, or None if not specified.


   .. method:: GetMin(self)

      Gets the minimum value of the control.  It will return the current
      minimum integer, or None if not specified.


   .. method:: GetValue(self)

      Returns the current integer (long) value of the control.


   .. method:: IsInBounds(self, value=None)

      Returns ``True`` if no value is specified and the current value
      of the control falls within the current bounds.  This function can
      also be called with a value to see if that value would fall within
      the current bounds of the given control.
      
      :param int `value`: value to check or None


   .. method:: IsLimited(self)

      Returns ``True`` if the control is currently limiting the
      value to fall within the current bounds.


   .. method:: IsLongAllowed(self)

      Is a long value allowed.


   .. method:: IsNoneAllowed(self)

      Is a None value allowed.


   .. method:: OnText( self, event )

      Handles an event indicating that the text control's value
      has changed, and issue EVT_INT event.
      NOTE: using wx.TextCtrl.SetValue() to change the control's
      contents from within a wx.EVT_CHAR handler can cause double
      text events.  So we check for actual changes to the text
      before passing the events on.


   .. method:: Paste( self )

      Override the :func:`TextCtrl.Paste` function, with our own
      that does validation.  Will raise ValueError if not a
      valid integerizable value.


   .. method:: SetBounds(self, min=None, max=None)

      This function is a convenience function for setting the min and max
      values at the same time.  The function only applies the maximum bound
      if setting the minimum bound is successful, and returns ``True`` only if both operations succeed.
      ..note::
        Leaving out an argument will remove the corresponding bound.
      
      :param int `min`: The value to be set as minimum
      
      :param int `max`: The value to be set as maximum


   .. method:: SetColors(self, default_color=wx.BLACK, oob_color=wx.RED)

      Tells the control what colors to use for normal and out-of-bounds
      values.  If the value currently exceeds the bounds, it will be
      recolored accordingly.
      
      :param Color `default_color`: default color to be used
      :param Color `oob_color`: out of bound color to be used


   .. method:: SetLimited(self, limited)

      If called with a value of True, this function will cause the control
      to limit the value to fall within the bounds currently specified.
      If the control's value currently exceeds the bounds, it will then
      be limited accordingly.
      
      If called with a value of 0, this function will disable value
      limiting, but coloring of out-of-bounds values will still take
      place if bounds have been set for the control.
      
      :param bool `limited`: If ``True`` set to control to be limited.


   .. method:: SetLongAllowed(self, allow_long)

      Change the behavior of the validation code, allowing control
      to have a long value or not, as appropriate.  If the value
      of the control is currently long, and allow_long is 0, the
      value of the control will be adjusted to fall within the
      size of an integer type, at either the sys.maxsize or -sys.maxsize-1,
      for positive and negative values, respectively.
      
      :param bool `allow_long`: If ``True`` allow long values for control


   .. method:: SetMax(self, max=None)

      Sets the maximum value of the control. If a value of None
      is provided, then the control will have no explicit maximum value.
      If the value specified is less than the current minimum value, then
      the function returns 0 and the maximum will not change from its
      current setting. On success, the function returns 1.
      
      If successful and the current value is greater than the new upper
      bound, if the control is limited the value will be automatically
      adjusted to this maximum value; if not limited, the value in the
      control will be colored with the current out-of-bounds color.
      
      If max > sys.maxsize and the control is configured to not allow longs,
      the function will return 0, and the max will not be set.
      
      :param int `max`: The value to be set as maximum


   .. method:: SetMin(self, min=None)

      Sets the minimum value of the control.  If a value of None
      is provided, then the control will have no explicit minimum value.
      If the value specified is greater than the current maximum value,
      then the function returns 0 and the minimum will not change from
      its current setting.  On success, the function returns 1.
      
      If successful and the current value is lower than the new lower
      bound, if the control is limited, the value will be automatically
      adjusted to the new minimum value; if not limited, the value in the
      control will be colored with the current out-of-bounds color.
      
      If min > -sys.maxsize-1 and the control is configured to not allow longs,
      the function will return 0, and the min will not be set.
      
      :param int `min`: The value to be set as minimum


   .. method:: SetNoneAllowed(self, allow_none)

      Change the behavior of the validation code, allowing control
      to have a value of None or not, as appropriate.  If the value
      of the control is currently None, and allow_none is 0, the
      value of the control will be set to the minimum value of the
      control, or 0 if no lower bound is set.
      
      :param bool `allow_none`: If ``True`` a None value is allowed


   .. method:: SetValue(self, value)

      Sets the value of the control to the integer value specified.
      The resulting actual value of the control may be altered to
      conform with the bounds set on the control if limited,
      or colored if not limited but the value is out-of-bounds.
      A ValueError exception will be raised if an invalid value
      is specified.
      
      :param int `value`: The value to be set


   .. attribute:: Limited

      Returns True if the control is currently limiting the
      value to fall within the current bounds.


   .. attribute:: LongAllowed

      Is a long value allowed.


   .. attribute:: Max

      Gets the maximum value of the control.  It will return the current
      maximum integer, or None if not specified.


   .. attribute:: Min

      Gets the minimum value of the control.  It will return the current
      minimum integer, or None if not specified.


   .. attribute:: NoneAllowed

      Is a None value allowed.


   .. attribute:: Value

      Returns the current integer (long) value of the control.


