Hello All!
I have 2 polygon-text interactions issue that are different from the ones in the forums so far. Since they may be inter-related, I’ve included both errors below.
OS Win 10
PsychoPy version (2024.1.2):
Standard Standalone? (y/n) yes
What are you trying to achieve?:
I have 3 polygons as 3 possible buttons that the participant can click on: rectangle1, rectangle2, and rectangle3
When a participant clicks on one of the rectangles,
the rectangle turns yellow and these polygons and texts appears:
a “submit” polygon button,
a “submit” text on top of the submit polygon button,
a “cancel” polygon button,
and a “cancel” text on top of the cancel polygon button should appear.
ERROR 1: currently, all except the “cancel” text appears.
Additionally, when the participant clicks on the cancel button,
the Submit polygon, submit text, cancel polygon, and cancel text should all disappear. In addition, the rectangle turns back to its original color (black)
ERROR 2: All except the “submit” text disappears.
What did you try to make it work?:
Under “Begin Routine”
cancel_button.opacity = 0
confirm_button.opacity = 0
button_is_pressed = False
Under “Each Frame”
#if cancel_button.contains(mouse_handler):
# cancel_button.fillColor = 'yellow'
# cancel_button_text.pos = (.35, -.85)
# cancel_button_text.color = 'black'
#else:
# cancel_button_text.pos = (.35, -.85)
# cancel_button_text.color = 'black'
if mouse_handler.isPressedIn(rectangle1):
button_is_pressed = True
else:
button_is_pressed = False
if button_is_pressed == True:
#make next button opaque
confirm_button.opacity = 1
confirm_button_text.opacity = 1
confirm_button_text.setText('Submit')
#CANCEL BUTTON (and text) APPEARS!
cancel_button.opacity = 1
cancel_button_text.opacity = 1
cancel_button_text.setText('Cancel')
## #ERROR: does not seem to register ##########################################
#cancel_button_text.opacity = 1
#cancel_button_text.setOpacity = 1
#cancel_button_text.updateOpacity(1)
#if click on cancel button, the text "Submit" should disappear
if mouse_handler.isPressedIn(cancel_button):
confirm_button_text.setText('Submit')
confirm_button_text.opacity = 0
confirm_button_text.opacity = 0
#if submit button clicked, display answer info and next button
if mouse_handler.isPressedIn(confirm_button):
#cancel button disappears
cancel_button.opacity = 0
#cancel_button_text.setOpacity = 0
#cancel_button_text.opacity = 0
if cancel_button.opacity == 1 and
mouse_handler.isPressedIn(cancel_button):
#make sure the next button says submit again when it reappears
confirm_button_text.setText('Submit')
#confirm button not visible
confirm_button.opacity = 0
confirm_button_text.opacity = 0
#submit button not visible either ...
confirm_choice_button_text.opacity = 0
confirm_choice_button.opacity = 0
#once clicked on, cancel button no longer visible
cancel_button.opacity = 0
cancel_button_text.opacity = 0
#no selection
button_is_pressed = False
What specifically went wrong when you tried that?:
Note that I did not receive any syntax errors nor other errors than those 2 listed above.
Additional changes I tried and commented out yielded no difference in appearance.
Tried setting the text to “Cancel” when I tried to make the cancel button opacity = 1 and set the text setOpacity = 1. (saw a post that recommended that)