View#

class blueprints.View[source]#

Bases: ViewType

The View class is used to handle the access to children of nodes in a kinematic tree and their properties.

Methods Summary

apply(function, *args, **kwargs)

Applies a function to all Things contained in View.

Methods Documentation

apply(function, *args, **kwargs)[source]#

Applies a function to all Things contained in View. Arguments and keyword arguments are passed to each individual call in an all to all relation.

>>> # keeping the view object from __setattr__
>>> renaming = lambda x: x.__setattr__('name', f'distal_{x.parent.parent.name}')
>>> view.bodies.bodies.apply(renaming)
>>> view.bodies.bodies.name
['distal_index', 'distal_middle', 'distal_ring', 'distal_pinky']
Parameters:
  • function (Callable) – Functions methods and classes are valid arguments.

  • *args – Arguments passed to each individual call.

  • **kwargs – Kexword arguments passed to each individual call.

Returns:

If any individual call results in a value that is not None, a list of all returned values gets returned, None otherwise.

Return type:

None | list

__init__(elements, name, parent)[source]#

The View can be used to get and set attributes of multiple objects at the same time.

Parameters:
  • elements (list) – All Things, that are part of the View.

  • name (str) – The name of the attribute that was requested for this View.

  • parent (blue.ThingType) – The parent of the View.

Return type:

None

classmethod __new__(*args, **kwargs)#