Esempio n. 1
0
    def __dict_changed(self, old, new):

        old_keys = set(old)
        new_keys = set(new)
        added   = sub_dict(new, new_keys - old_keys)
        removed = sub_dict(old, old_keys - new_keys)
        changed = sub_dict(old, new_keys & old_keys)

        self._post_event(
            TraitDictEvent(added=added, changed=changed, removed=removed)
        )
Esempio n. 2
0
    def _context_data_changed ( self, old, new ):
        """ Fires when 'context_data' is changed.
        """

        if old is None:
            old = {}
        else:
            old.on_trait_event( self._dict_is_modified, 'dict_modified',
                                remove = True )

        new.on_trait_event( self._dict_is_modified, 'dict_modified' )

        old_keys = set( old )
        new_keys = set( new )
        added   = sub_dict( new, new_keys - old_keys )
        removed = sub_dict( old, old_keys - new_keys )
        changed = sub_dict( old, new_keys & old_keys )

        self._dict_is_modified(
            TraitDictEvent( added=added, changed=changed, removed=removed )
        )