How to make a copy of image and change its attributes

OS : Win10
PsychoPy version : v2022.1.1
Standard Standalone? (y/n) : Yes

Hi all, I am trying to make an experiment where there are several images on the screen, and once participants click on one of the images, a copy of that image will appear in another area. (Imagine you are shopping online, and once you click on one product, that product gets into your cart). The problem I am running into is copying the imageStim and changing the position.

I understand that I can’t just use the ‘=’ operator and need to use the copy module. This is what I write:
(let’s say I click on image1):

import copy
newImage = copy.copy(image1)
newImage.pos = (-0.2, -0.2)
image1.pos #([0.15, 0.33])
newImage.pos #([-0.2, -0.2])

I checked imag1.pos and newImage.pos, they have different numbers. But when I draw them, they are in the same position on the screen.

I am not familiar with python so I don’t understand what the problem is. I;ve tried using copy.deepcopy, but there is an error saying that “ctypes objects containing pointers cannot be pickled” .

Any suggestions on how I should make a copy of the image or how to fix the copy.copy issue? Thank you very much!

I’ve not heard of the copy module, but couldn’t you create a newImage as you would a normal image and then set newImage.setImage(image1.image) or similar?

Thank you for replying! I find a solution in the dragAndDrop demo by making a function to basically do what you say, creating a newImage.

I know about the copy module from this post.