def dropEvent(self, e: QDropEvent): targets = self.targetedItems(e.pos()) if len(targets) > 0: s = "%s%d%d" it = targets[0] act = self.lastSelection[0] if act == 'r': d = it.row elif act == 'c': d = it.col elif act == 'b': d = self.whichBlock(it.row, it.col)[2] s = s % (self.lastSelection[0], self.lastSelection[1] + 1, d + 1) self.textFromInterpreter(s) e.setAccepted(True) super(Canvas, self).dropEvent(e) pass