Changing size of a picture with a slider component

Hi everyone:)

I’m currently working on a PsychoPy experiment and could use some assistance. I’m trying to design a routine where participants adjust the height of an image (y-axis) using a slider. The concept is similar to the screenscale experiment (Wakefield Morys-Carter / ScreenScale · GitLab), but I’m looking to achieve this without using keys, and I only want to modify the height, not the width of the image.

Moreover, I aim to present the image twice in the experiment: in the first routine, the picture should be smaller than the original, and in the second one, it should be taller. Unfortunately, my coding skills are limited, and despite my attempts to modify the code, it’s not functioning as intended.

Any help is greatly appreciated!

Best,
Theresa

Begin Experiment:

oldt = 0
screen_height = 0

if win.units==‘norm’:
x_scale=.05
y_scale=.1
dbase = .0001
unittext=’ norm units’
vsize=2
elif win.units==‘pix’:
x_scale=60
y_scale=40
dbase = .1
unittext=’ pixels’
vsize=win.size[1]
else:
x_scale=.05
y_scale=.05
dbase = .0001
unittext=’ height units’
vsize=1

Each Frame:
slider_value = slider.getRating()

if t - oldt < 0.5:
dscale = 5 * dbase
oldt = t
else:
dscale = dbase
oldt = t

current_y_size = 3 * y_scale

if slider_value > 0:
y_scale = round((y_scale + dscale) * 10000) / 10000
elif slider_value < 0:
y_scale = round((y_scale - dscale) * 10000) / 10000

ubimage_3.size = [10, 3 * y_scale]

End Routine:
thisExp.addData(‘Y Scale’,y_scale)

I also defined the size of the picture: $(10, 3*y_scale)