3.1.3
Notification Handler Signatures
The handler passed to on_trait_change() or on_trait_event()
can have any one of the following signatures:
handler()
handler(new)
handler(name, new)
handler(object, name, new)
handler(object, name, old, new)
These signatures use the following parameters:
·
object—The object whose trait
attribute changed.
·
name—The attribute that changed. If
one of the objects in a sequence is a List or Dict, and its membership changes,
then this is the name of the trait that reference it, with _items appended. For example, if the handler is
monitoring 'foo.bar.baz',
where bar is a List, and an item is added
to bar, then the value of the name parameter is bar_items.
·
new—The new value of the trait attribute
that changed. For changes to List and Dict objects, this is a list of items
that were added.
·
old—The old value of the trait
attribute that changed. For changes to List and Dict object, this is a list of
items that were deleted. For event traits, this is Undefined.
If the handler is a bound method, it also implicitly has self as a first argument.
|