3.2.3
Attribute-specific Handler Signatures
For an attribute specific notification handler, the method
signatures supported are:
_name_changed(self)
_name_changed(self, new)
_name_changed(self, old, new)
_name_changed(self, name, old, new)
The method name can also be _name_fired(),
with the same set of signatures.
In these signatures:
·
new is the new value assigned to
the trait attribute. For List and Dict objects, this is a list of the items
that were added.
·
old is the old value assigned to
the trait attribute. For List and Dict objects, this is a list of the items
that were deleted.
·
name is the name of the trait
attribute. The extended trait name syntax is not supported.[4]
Note that these signatures follow a different pattern for
argument interpretation from dynamic handlers and decorated static handlers.
Both of the following methods define a handler for an object’s name trait:
def _name_changed( self, arg1, arg2, arg3):
pass
@on_trait_change('name')
def some_method( self, arg1, arg2, arg3):
pass
However, the interpretation of arguments to these methods
differs, as shown in Table 6.
Table 6 Handler argument interpretation
|
Argument
|
_name_changed
|
@on_trait_change
|
|
arg1
|
name
|
object
|
|
arg2
|
old
|
name
|
|
arg3
|
new
|
new
|
|