observe(handler, names=traitlets.All, type='change')¶
Setup a handler to be called when a trait changes.
This is used to setup dynamic notifications of trait changes.
handler (callable) – A callable that is called when a trait changes. Its signature should be
changeis a dictionary. The change dictionary at least holds a ‘type’ key. *
type: the type of notification. Other keys may be passed depending on the value of ‘type’. In the case where type is ‘change’, we also have the following keys: *
owner: the HasTraits instance *
old: the old value of the modified trait attribute *
new: the new value of the modified trait attribute *
name: the name of the modified trait attribute.
names (list, str, All) – If names is All, the handler will apply to all traits. If a list of str, handler will apply to all names in the list. If a str, the handler will apply just to that name.
type (str, All (default: 'change')) – The type of notification to filter by. If equal to All, then all notifications are passed to the observe handler.