code: def set_callback(self, ref, callback):
          
          # if the callback already exists, remove it
          self.remove_callback(ref)
  
          # add it to the callbacks
          if callback is not None:
              self._callbacks[ref] = callback
docs: Sets a callback for a ref (reference), setting to None will remove it