Package param :: Class ObjectSelector
[hide private]
[frames] | no frames]

Class ObjectSelector

source code


Parameter whose value is set to an object from its list of possible objects.

check_on_set restricts the value to be among the current list of objects. By default, if objects are initially supplied, check_on_set is True, whereas if no objects are initially supplied, check_on_set is False. This can be overridden by explicitly specifying check_on_set initially.

If check_on_set is True (either because objects are supplied initially, or because it is explicitly specified), the default (initial) value must be among the list of objects (unless the default value is None).

Nested Classes [hide private]

Inherited from parameterized.Parameter: __metaclass__

Instance Methods [hide private]
 
__init__(self, default=None, objects=None, instantiate=False, compute_default_fn=None, check_on_set=None, **params)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
compute_default(self)
If this parameter's compute_default_fn is callable, call it and store the result in self.default.
source code
 
_check_value(self, val, obj=None)
val must be None or one of the objects in self.objects.
source code
 
__set__(self, obj, val)
Set the value for this Parameter.
source code
 
get_range(self)
Return the possible objects to which this parameter could be set.
source code

Inherited from parameterized.Parameter: __delete__, __get__, __getstate__, __setstate__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  __classdoc = '\n Parameter whose value is set to an object ...
str(object) -> string
Properties [hide private]
  check_on_set
  compute_default_fn
  objects

Inherited from parameterized.Parameter: constant, default, doc, instantiate, pickle_default_value, precedence, readonly

Inherited from object: __class__

Method Details [hide private]

__init__(self, default=None, objects=None, instantiate=False, compute_default_fn=None, check_on_set=None, **params)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

compute_default(self)

source code 

If this parameter's compute_default_fn is callable, call it and store the result in self.default.

Also removes None from the list of objects (if the default is no longer None).

__set__(self, obj, val)

source code 

Set the value for this Parameter.

If called for a Parameterized class, set that class's value (i.e. set this Parameter object's 'default' attribute).

If called for a Parameterized instance, set the value of this Parameter on that instance (i.e. in the instance's __dict__, under the parameter's internal_name).

If the Parameter's constant attribute is True, only allows the value to be set for a Parameterized class or on uninitialized Parameterized instances.

If the Parameter's readonly attribute is True, only allows the value to be specified in the Parameter declaration inside the Parameterized source code. A read-only parameter also cannot be set on a Parameterized class.

Note that until we support some form of read-only object, it is still possible to change the attributes of the object stored in a constant or read-only Parameter (e.g. the left bound of a BoundingBox).

Overrides: parameterized.Parameter.__set__
(inherited documentation)

get_range(self)

source code 

Return the possible objects to which this parameter could be set.

(Returns the dictionary {object.name:object}.)

Overrides: Selector.get_range

Class Variable Details [hide private]

__classdoc

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

Value:
'''
    Parameter whose value is set to an object from its list of
    possible objects.

    check_on_set restricts the value to be among the current list of
    objects. By default, if objects are initially supplied,
    check_on_set is True, whereas if no objects are initially
    supplied, check_on_set is False. This can be overridden by
...