macOS Mojave 10.14.6
PsychoPy version 3 2020.2.10
Hello, I have been using PsychoPy to build a task and have had a persistent issue in the text component with concatenating/formatting strings. I have a variable “propString” that was a number that I converted to a string. I wanted to print it on a line with a percent symbol, " %". I emulated this video and other descriptions online and my code looks no different than how you typically concatenate a string:
As you can see, I receive a Python syntax error. This occurs even if I use single quotations or double, and if I try other ways of string formatting such as:
However, when I concatenate/format the string in the coder as seen below, I receive no such error and my experiment runs fine with the concatenated string:
percentage.setText(propString + " %")
However, that’s not ideal since changes that you make in the coder don’t transfer to the builder/psyexp file. So I came to a different workaround where in a code component, I concatenate the string there rather than in the text component (see below). This works fine and achieves the desired result:
propString = str(proportion) + " %"
This is quite odd that the builder is preventing me from concatenating/formatting strings, but this is something that other users are clearly able to do. Furthermore, it’s something I can easily achieve with code but not in the builder so it leads me to suspect that something wrong is going on with my builder.
I have tested this with other strings besides “%” as I thought maybe it was a symbol issue and this problem occurs if I try to concatenate the variable with any string. The variable is already a string, by the way.
Can anyone provide me with any advice or recommendations on how to fix this problem in my Psychopy builder?