psychopy.org | Reference | Downloads | Github

Background routine running and triggering the flow when condition is met

Hi,

I am acquiring temperature from an external device in a small python GUI. I would like that when I push the button “Ready to start” on that GUI (see picture) , it triggers the first trial in FLOW (some text in the main psychopy window) without ending the temperature GUI.

So far ending the GUI has been the only way to start the trials in FLOW. I have included the code for the small temperature GUI in the first trial in FLOW under the field “Begin experiment”. I was hoping that adding “continueRoutine = False” as the code to be run when “Ready to Start” is pressed would do the job (see below). Apparently not. The only code that allows flow to run is “self.quit()” for the GUI appalication. And then then I cannot have a look at the temperature.

In the future, the GUI will be shown on a control screen and teh stimulus window on a stimulus screen. I will be able to have a look at the temperature or set it to another level. i am not there yet. For the moment, I would just like to trigger the first trial from the contro GUI and to keep logging temperature as psychopy experiment runs.

Should I multithread it? I have to inform that I am new to python and psychopy, but not in other programming languages. I generally use Neurobs Presentation.

Thank you,

The ideal would be to bring your Python temperature GUI code into your PsychoPy experiment code. Run one PsychoPy window for your task, and another PsychoPy window to show temperature. That way, both windows are being controlled from the same Python process and you won’t get conflicts over who is controlling the GUI and receiving events.

Thank you Michael. Including the gui in the Psychopy code is the way to go.
I first did as you recommended with two psychopy windows and from that I understood that the “.mainloop” of the gui was the issue.
If we refer to the picture above with the code,I replaced “.mainloop” with “.update()” in the “Begin Experiment” and add “app.update()” in the “Each Frame” field.

I would think that you should not be creating an extra application. There should be just one application (your experiment), which controls two windows. Builder automatically creates one window to show your stimuli in. You just need to insert some code in the “Begin experiment” tab to create a second one (likely on a second monitor). This would just be standard PsychoPy window, created something like this:

temperature_win = visual.Window(size = [200, 200], monitor = 1) # etc

as per the API here:

http://www.psychopy.org/api/visual/window.html#psychopy.visual.Window