traits.trait_set_object Module

Classes

class traits.trait_set_object.TraitSetEvent(removed=None, added=None)[source]

An object reporting in-place changes to a traits sets.

Parameters
  • added (dict or None) – New values added to the set, or optionally None if nothing was added.

  • removed (dict or None) – Old values that were removed, or optionally None if nothing was removed.

added

New values added to the set. If nothing was added this is an empty set.

Type

dict

removed

Old values that were removed. If nothing was removed this is an empty set.

Type

dict

class traits.trait_set_object.TraitSetObject(trait, object, name, value)[source]

A subclass of set that fires trait events when mutated.

This is used by the Set trait type, and all values set into a Set trait will be copied into a new TraitSetObject instance.

Mutation of the TraitSetObject will fire a “name_items” event with appropriate added and removed values.

Parameters
  • trait (CTrait instance) – The CTrait instance associated with the attribute that this Set has been set to.

  • object (HasTraits instance) – The HasTraits instance that the set has been set as an attribute for.

  • name (str) – The name of the attribute on the object.

  • value (set) – The set of values to initialize the TraitSetObject with.

trait

The CTrait instance associated with the attribute that this set has been set to.

Type

CTrait instance

object

A weak reference to a HasTraits instance that the set has been set as an attribute for.

Type

weak reference to a HasTraits instance

name

The name of the attribute on the object.

Type

str

name_items

The name of the items event trait that the trait set will fire when mutated.

Type

str

update(value)[source]

Update a set with the union of itself and others.

intersection_update(value)[source]

Update a set with the intersection of itself and another.

difference_update(value)[source]

Remove all elements of another set from this set.

symmetric_difference_update(value)[source]

Update a set with the symmetric difference of itself and another.

add(value)[source]

Add an element to a set.

This has no effect if the element is already present.

remove(value)[source]

Remove an element from a set; it must be a member.

If the element is not a member, raise a KeyError.

discard(value)[source]

Remove an element from a set if it is a member.

If the element is not a member, do nothing.

pop()[source]

Remove and return an arbitrary set element. Raises KeyError if the set is empty.

clear()[source]

Remove all elements from this set.