def append_reference_code(self, key, ref_key, ref_type="absolute"):
        """Appends reference code to cell code.

        Replaces existing reference.

        Parameters
        ----------
        key: 3-tuple of Integer
        \tKey of cell that gets the reference
        ref_key: 3-tuple of Integer
        \tKey of cell that is referenced
        ref_type: Sting in ["absolute", "relative"]
        \tAn absolute or a relative reference is added

        """

        if ref_type == "absolute":
            code = self._get_absolute_reference(ref_key)

        elif ref_type == "relative":
            code = self._get_relative_reference(key, ref_key)

        else:
            raise ValueError(_('ref_type has to be "absolute" or "relative".'))

        old_code = self.grid.code_array(key)

        if old_code is None:
            old_code = u""

        if "S" in old_code and old_code[-1] == "]":
            old_code_left, __ = old_code.rsplit("S", 1)
            new_code = old_code_left + code
        else:
            new_code = old_code + code

        post_command_event(self.grid.main_window, self.EntryLineMsg,
                           text=new_code)

        return new_code
Appends reference code to cell code.

        Replaces existing reference.

        Parameters
        ----------
        key: 3-tuple of Integer
        \tKey of cell that gets the reference
        ref_key: 3-tuple of Integer
        \tKey of cell that is referenced
        ref_type: Sting in ["absolute", "relative"]
        \tAn absolute or a relative reference is added