API Reference for Enthought Tool Suite 2.7.1

Ensures that a trait attribute lies within a specified numeric range.

TraitRange is the underlying handler for the predefined Range() trait factory.

Any value assigned to a trait containing a TraitRange handler must be of the correct type and in the numeric range defined by the TraitRange instance. No automatic coercion takes place. For example:

class Person(HasTraits):
    age = Trait(0, TraitRange(0, 150))
    weight = Trait(0.0, TraitRange(0.0, None))

This example defines a Person class, which has an age trait attribute, which must be an integer/long in the range from 0 to 150, and a weight trait attribute, which must be a non-negative float value.

Inherits from

Method summary

Methods

Copyright © 2002-2008 Enthought, Inc.