utils Module

class tallypi.utils.SetProperty(default=None, copy_on_change=False)[source]

Bases: pydispatch.properties.Property

Property with a set type value

Parameters
  • default (Optional) – If supplied, this will be the default value of the Property for all instances of the class. Otherwise None

  • copy_on_change (bool, optional) – If True, the set will be copied when contents are modified. This can be useful for observing the original state of the set from within callbacks. The copied (original) state will be available from the keyword argument ‘old’. The default is False (for performance and memory reasons).

Changes to the contents of the set are able to be observed through ObservableSet.

class tallypi.utils.ObservableSet(initset=None, **kwargs)[source]

Bases: set, pydispatch.properties.Observable

A set subclass that tracks changes to its contents

add(item)[source]

Add an element to a set.

This has no effect if the element is already present.

discard(item)[source]

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

If the element is not a member, do nothing.

remove(item)[source]

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

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

pop()[source]

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

clear()[source]

Remove all elements from this set.