# Set image position based on previous screen

**URL:** https://discourse.psychopy.org/t/set-image-position-based-on-previous-screen/24720
**Category:** Coding
**Created:** [August 27, 2021, 9:57pm UTC](https://discourse.psychopy.org/t/set-image-position-based-on-previous-screen/24720 "2021-08-27T21:57:02Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![tuenyj98](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tuenyj98/32/30877_2.png) [@tuenyj98](https://discourse.psychopy.org/u/tuenyj98)
#### Post date: [August 27, 2021, 9:57pm UTC](https://discourse.psychopy.org/t/set-image-position-based-on-previous-screen/24720/1 "2021-08-27T21:57:02Z")

</div>

Hi! I’m trying to set the position of an image (e.g., TD\_Correct in Routine 2) to be the same as an image that appeared in the previous routine (e.g., TO\_Correct in Routine 1).

Right now, TO\_Correct and TO\_Incorrect (in Routine 1; see below) are coded to appear either on the left or right of the screen and I want to make sure that in the next routine, the positions of TD\_Correct and TD\_Incorrect correspond to TO\_Correct and TO\_Incorrect respectively.

Is there some code that I can use to achieve this? Thank you 🙂

**Routine 1:**

 ![Screen Shot 2021-08-27 at 2.49.42 PM](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/f/f/ff69d32cf334bd8e2d0712b637007aaaf6cc5805.png)

**Code for TO\_Correct and TO\_Incorrect position:**  
imPositions = [(-0.35, 0), (0.35, 0)]  
shuffle(imPositions) # to randomize first position  
TO\_Correct.setPos(imPositions[0])  
TO\_Incorrect.setPos(imPositions[1])

**Routine 2:**

 ![Screen Shot 2021-08-27 at 2.50.09 PM](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/f/9/f91f52a5418104f1bf6c5568fe53800335e4dbc7.png)

---

<div class="post-metadata">

### Author: ![sal](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@sal](https://discourse.psychopy.org/u/sal)
#### Post date: [August 30, 2021, 7:24pm UTC](https://discourse.psychopy.org/t/set-image-position-based-on-previous-screen/24720/2 "2021-08-30T19:24:02Z")

</div>

If I’m understanding correctly, you would just use the same code you already have but add `TD_Correct.setPos(imPosition[0])` (and with incorrect). Then it will set them both at the same time.

---

<div class="post-metadata">

### Author: ![tuenyj98](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tuenyj98/32/30877_2.png) [@tuenyj98](https://discourse.psychopy.org/u/tuenyj98)
#### Post date: [September 3, 2021, 4:50pm UTC](https://discourse.psychopy.org/t/set-image-position-based-on-previous-screen/24720/3 "2021-09-03T16:50:14Z")

</div>

Thanks for your help sal! It turns out I just needed to include the following code and I managed to have the images be in the same position for the TD and TO routines:

TD\_Correct.setPos(TO\_Correct.pos) #set image positions to be the same as in the TO task  
TD\_Incorrect.setPos(TO\_Incorrect.pos)
