Package wx :: Package lib :: Module intctrl :: Class IntCtrl
[frames | no frames]

Type IntCtrl

object --+                    
         |                    
    Object --+                
             |                
    EvtHandler --+            
                 |            
            Window --+        
                     |        
               Control --+    
                         |    
                  TextCtrl --+
                             |
                            IntCtrl


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

IntCtrl(
parent, id = -1, value = 0, pos = wxDefaultPosition, size = wxDefaultSize, style = 0, validator = wxDefaultValidator, name = "integer", min = None, max = None, limited = False, allow_none = False, allow_long = False, default_color = wxBLACK, oob_color = wxRED )
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 SetValue() after instantiation of the control.)
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.maxint-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.maxint-1.
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.maxint 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.maxint.
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.
allow_none
Boolean indicating whether or not the control is allowed to be empty, representing a value of None for the control.
allow_long
Boolean indicating whether or not the control is allowed to hold and return a long as well as an int.
default_color
Color value used for in-bounds values of the control.
oob_color
Color value used for out-of-bounds values of the control when the bounds are set but the control is not limited.
validator
Normally None, IntCtrl uses its own validator to do value validation and input control. However, a validator derived from IntValidator can be supplied to override the data transfer methods for the IntValidator class.

Method Summary
  __init__(self, parent, id, value, pos, size, style, validator, name, min, max, limited, allow_none, allow_long, default_color, oob_color)
  Cut(self)
Override the wxTextCtrl's .Cut function, with our own that does validation.
  GetBounds(self)
This function returns a two-tuple (min,max), indicating the current bounds of the control.
  GetColors(self)
Returns a tuple of (default_color, oob_color), indicating the current color settings for the control.
  GetMax(self)
Gets the maximum value of the control.
  GetMin(self)
Gets the minimum value of the control.
  GetValue(self)
Returns the current integer (long) value of the control.
  IsInBounds(self, value)
Returns True if no value is specified and the current value of the control falls within the current bounds.
  IsLimited(self)
Returns True if the control is currently limiting the value to fall within the current bounds.
  IsLongAllowed(self)
  IsNoneAllowed(self)
  OnText(self, event)
Handles an event indicating that the text control's value has changed, and issue EVT_INT event.
  Paste(self)
Override the wxTextCtrl's .Paste function, with our own that does validation.
  SetBounds(self, min, max)
This function is a convenience function for setting the min and max values at the same time.
  SetColors(self, default_color, oob_color)
Tells the control what colors to use for normal and out-of-bounds values.
  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.
  SetLongAllowed(self, allow_long)
Change the behavior of the validation code, allowing control to have a long value or not, as appropriate.
  SetMax(self, max)
Sets the maximum value of the control.
  SetMin(self, min)
Sets the minimum value of the control.
  SetNoneAllowed(self, allow_none)
Change the behavior of the validation code, allowing control to have a value of None or not, as appropriate.
  SetValue(self, value)
Sets the value of the control to the integer value specified.

Property Summary

Instance Method Details

Cut(self)

Override the wxTextCtrl's .Cut function, with our own that does validation. Will result in a value of 0 if entire contents of control are removed.

Overrides:
wx.TextCtrl.Cut

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.

GetColors(self)

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

GetMax(self)

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

GetMin(self)

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

GetValue(self)

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

Overrides:
wx.TextCtrl.GetValue

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.

IsLimited(self)

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

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.

Paste(self)

Override the wxTextCtrl's .Paste function, with our own that does validation. Will raise ValueError if not a valid integerizable value.

Overrides:
wx.TextCtrl.Paste

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.

SetColors(self, default_color=wx.Colour(), oob_color=wx.Colour())

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.

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.

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.maxint or -sys.maxint-1, for positive and negative values, respectively.

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.maxint and the control is configured to not allow longs, the function will return 0, and the max will not be set.

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.maxint-1 and the control is configured to not allow longs, the function will return 0, and the min will not be set.

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.

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.

Overrides:
wx.TextCtrl.SetValue

Generated by Epydoc 2.1.20050511.rpd on Mon Feb 16 12:53:01 2009 http://epydoc.sf.net