Sets a callback for a ref (reference), setting to None will remove it

def set_callback(self, ref, callback):
        """
        Sets a callback for a ref (reference), setting to None will remove it
        """
        # 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