3
Trait Notification
When the value of an attribute changes, other parts of the
program might need to be notified that the change has occurred. The Traits
package makes this possible for trait attributes. This functionality lets you
write programs using the same, powerful event-driven model that is used in
writing user interfaces and for other problem domains.
Requesting trait attribute
change notifications can be done in several ways:
·
Dynamically, by calling on_trait_change() or on_trait_event() to
establish (or remove) change notification handlers.
·
Statically, by decorating methods on the class with the
@on_trait_change decorator to indicate that they handle notification for
specified attributes.
·
Statically, by using a special naming convention for methods on
the class to indicate that they handle notifications for specific trait
attributes.
|