def connect(self, event, func=None):
        """
        Connect a callback to a `Cursor` event; return the callback.

        Two events can be connected to:

        - callbacks connected to the ``"add"`` event are called when a
          `Selection` is added, with that selection as only argument;
        - callbacks connected to the ``"remove"`` event are called when a
          `Selection` is removed, with that selection as only argument.

        This method can also be used as a decorator::

            @cursor.connect("add")
            def on_add(sel):
                ...

        Examples of callbacks::

            # Change the annotation text and alignment:
            lambda sel: sel.annotation.set(
                text=sel.artist.get_label(),  # or use e.g. sel.target.index
                ha="center", va="bottom")

            # Make label non-draggable:
            lambda sel: sel.draggable(False)
        """
        if event not in self._callbacks:
            raise ValueError("{!r} is not a valid cursor event".format(event))
        if func is None:
            return partial(self.connect, event)
        self._callbacks[event].append(func)
        return func