Click and drag code doesn't work

A very simple version of the drag and drop was shown to me in this thread (so hopefully you can adapt it for your needs):

The key python part (from the demo above also) is

if mousePressedIn(draggedImage):
  draggedImage.pos = mouse.get Pos()