Using the latest version of PsychoPy (v2024.1.4) on Windows.
I’m not sure what else to try/if it’s possible to change text component orientation dynamically, does anyone have any advice?
I have a text component in my experiment that needs to update the orientation to match the index which I set it at. Just as a bit more context, I declared probe_orientation and probe_word as global variables in Begin Experiment.
Here is where I make the list of words (chosen from a larger array defined earlier in the experiment which works in other tasks):
((( #shuffles the entire array
shuffle(words)
#memorization trial words and orientations
#the first 32 words from the array are chosen
old_words=words[0:32]
#16 of them are upright, 16 of them are inverted 180 degrees
old_orientations = [0] * 16 + [180] * 16
#shuffling the order in which the inversion assignments are in
shuffle(old_orientations)
#combining test trial words and orientations
ow_len = len(old_words) # assigning a variable to length of old words to avoid Pavlovia bugs
old_word_orientations = #emptying any prior values
for Idx in range(ow_len): # creates an index for the length of the list
old_word_orientations.append([old_words[Idx], old_orientations[Idx%len(old_orientations)]]) # combining the two lists and indexing orientations to items in old_words
shuffle(old_word_orientations) #shuffling the entire list
#assign the new word list
new_words = words[33:65]
new_list = [word for word in new_words if word not in old_words] #taking the new words as long as they weren’t found in old words
old_upright = [old_words[i] for i in range(len(old_words)) if old_orientations[i] == 0] # defining which words were upright
old_inverted = [old_words[i] for i in range(len(old_words)) if old_orientations[i] == 180] # and which were inverted
Shuffle old words outside the function to avoid multiple shuffles
shuffle(old_words)
#Creation of a function to assign and flip words
def assign_and_flip(words, original_ori, flip_ori): #alternates between flipping the orientation and keeping the same orientation
stay = [(words[i], original_ori) for i in range(8)]
flip = [(words[i + 8], flip_ori) for i in range(8)]
return stay + flip #return the output of that
Apply the function to old word lists
NI_II = assign_and_flip(old_upright, 180, 0) #take the original word, invert it
NN_IN = assign_and_flip(old_inverted, 0, 180) #take the original word, make it normal
Sample 32 unique new words
new_words_sampled = new_list[0:32] # takes new words from the new list
Assign orientations to new words
shuffle(new_words_sampled) #shuffles those taken
WN = [(new_words_sampled[i], 0) for i in range(16)] #randomly keep 16 words in the same orientation
WI = [(new_words_sampled[i], 180) for i in range(16, 32)]
Combine all lists and shuffle
full_list =
full_list.extend(NI_II)
full_list.extend(NN_IN)
full_list.extend(WN)
full_list.extend(WI)
shuffle(full_list) )))
#setting both indices to the first number
current_index = 0
recognition_index = 0
##########################################
put a screen with just an asterisk after all this to see if the code above is the source of the issue, but the asterisk shows in pavlovia.
I tried
probe_word, probe_orientation = old_word_orientations[current_index]
which works locally but not on Pavlovia, it gives an error that probe_word is not defined.
Tried going to the orientation attribute and putting
old_word_orientations[current_index]
as well as
old_word_orientations[current_index][1]
neither of which work. Don’t give an error but just the screen is blank, can’t see any console errors.
Tried using probe_orientation=old_word_orientations[current_index][1]
and it says probe_orientation isn’t defined
Tried using the setOri function, which didn’t do anything at all (blank), and .thisN which was also a bust. Also, when I set the orientation to blank so that the .draw() function works, it says it can’t read “None”, and when I put 0, it overrides the .draw() function.