Canvas: changing text elements
Dear Forum,
I have created a canvas with several text elements that display the values of float variables. Here is one example of the text elements that display the value of a float variable:
upper_safe_amount = 45.00
my_canvas["upper_safe_amount"] = Text("%.2f"%upper_safe_amount,center=True, x=-256, y=-192)
Since the value of the float variable needs to change over the course of the experiment, I was wondering how to reflect these changes in the canvas text element? So, in other words, after performing changes of the float variable upper_safe_amount, what do I need to do in order to change the text displayed accordingly?
Looking forward to your suggestions 😊
Thanks in advance & best,
Sarah
Comments
Hi Sarah,
If the change of the float variable and the generation of the canvas are both in the same loop, you don't need to do anything. Opensesame will use whichever value is currently stored in
upper_safe_amount.if you generate the canvas once, and want to present the updated value later, you can do:
my_canvas["upper_safe_amount"].text = "%.2f"%upper_safe_amount
When you then call canvas.show() again, the value should have been updated.
But best to try it out and see what happens. See you also here.
Good luck,
Eduard
Hi Eduard,
Thanks a lot for your fast reply - the second one worked perfectly!
Best,
Sarah