class controls.ValueField(TextField)

ValueField is an abstract base class for widgets editing values of type other than string. It provides a framework for converting between the textual representation used for editing and the value used by the application.

Useful subclasses of ValueField include IntField and FloatField.

Constructor

ValueField(width)
The width is specified as for TextField.

Attributes

format
A format string used for converting the external value to its textual representation. The default is "%s".
type
A function for converting the textual representation to an external value. There is no default value; subclasses must provide it.
empty
If this is given a value, it indicates that the field may be left empty, and the value specified is the one be used as the external value in this case. Note that None is a valid value for this attribute; to make it unspecified, use NotImplemented.

Methods

get_value()
set_value(value)
Gets and sets the external value. The value is converted to and from textual representation automatically. If get_value() is called when the field does not contain a valid textual value for the type concerned, an exception will be raised. This includes the case where the field is empty and no value for the empty attribute has been specified.

Abstract Methods

format_value(value)
This method is called to convert a value to textual representation. The default implementation uses the format string. A subclass can override this if a different kind of formatting is required.
---