Ending loop conditionnally. While loop?

No, that code is “raw Python” and wouldn’t work well in the PsychoPy environment. e.g.

  • raw_input() is designed to just get simple keyboard responses when Python scripts are run from the command line and people automatically get to see what they are typing directly.

  • In PsychoPy, we use graphical windows and only show people what they type if we choose to do so. Also, we can’t use infinite loops like while True: in Builder, because Builder is predicated on a cycle of drawing to the screen on every screen refresh (typically 60 times a second), so we can’t use code that will take an indefinite pause.

  • This code is trying to get a keyboard response, whereas you want to click on stimulus with a mouse.

The good news is that this is a common request. Look at previous questions on this forum and see if they help:

https://discourse.psychopy.org/search?q=mouse%20select