Code component after expInfo dialog box but before window creation possible in builder?

OS Win10:
PsychoPy version 2020.2.10:
Standard Standalone? y :
What are you trying to achieve?:
I have some code that checks the participant and session numbers in expInfo and determines whether data have already been collected for that subject. If data have already been collected, it will create a dialog box that asks if the experimenter wants to proceed, quit, etc.

This works beautifully if I manually put in this chunk of code after the section “#Store info about the experiment session,” i.e. where expInfo is defined. However, since I want to keep everything in Builder, it is a nuisance to manually put the code there every time I want to make a new script/update some other part of the experiment.

What did you try to make it work?:
I’ve tried putting the code into a code component “Before Experiment,” but this places the code before expInfo is defined. If I put in the “Begin Experiment” tab, the window gets created before my code executes, and my dialog box never appears.

I’ve also tried putting the code that I need my code to go after (i.e. “Store info about the experiment session”) before my code in the “Before Experiment” tab, and then unchecking the “show info dialog box” in Builder. This almost works, but the script automatically makes another “Store info about the experiment session” section, which resets expInfo to empty, which causes a host of issues.

Any idea if this is possible? It would make my life a lot easier since I am implementing these logical checks in every task that I use.


Your dialog window won’t show, as the main window is created full screen. This is by design, because by hogging the entire interface, a full screen window can achieve better performance. The dialog may in fact exist, but is simply hidden behind the main one. You have a few alternatives:

  • in your code, minimize the main window so your dialog can be seen. If continuing, you then need to activate the main window again. There are posts on this forum showing the code to use for that. This approach allows you to use the regular “begin experiment” tab of a code component.
  • don’t muck around with a dialog window, but instead just use regular PsychoPy routines and stimuli to give feedback to the experimenter and allow them to quit. This is probably the neater, easier and less error-prone approach. eg by maintaining a full-screen window, the user can’t accidentally click into another app and get confused.

Actually this might be the best resource for minimizing if you go that route:

1 Like

Thanks! These are both great suggestions.

I think I’ll just provide feedback w/ a routine.