psychopy.org | Reference | Downloads | Github

In Builder view, how to bring an interactive dialogue box in front of a background after a loop?

Win7
PsychoPy version: 1.84.2
What are you trying to achieve?
I’m trying to display an interactive dialogue box after participant performs a block (loop) of trials to ask them to enter worlds or/and numbers that must be then saved for later analysis.

I would really appreciate any help. Thanks!

What did you try to make it work?:
This is the code I have so far after a loop:

Begin Experiment:

from psychopy import gui

Begin Routine:

background = visual.Window(fullscr=False, color =[0,0,], size=[5000, 5000], allowGUI=False) # optional: a temporary big window to hide the desktop/app to the participant
background.show()

myDlg = gui.Dlg(title=“Yor description of the task”)
myDlg.addField(‘Blue Deck: What percentage of times you get response A:’)
myDlg.addField(’ you get response B:’)
myDlg.addField(‘Red Deck: What percentage of times you get response A:’)
myDlg.addField(’ you get response B:’)
myDlg.show()

event.waitKeys()

ok_data = myDlg.show() # show dialog and wait for OK or Cancel
if myDlg.OK: # or if ok_data is not None
print(ok_data)
else:
print(‘User cancelled’)

I have found some bits of code in this thread Why does my dialogue box not show when fullscr=True?, but can’t get my head around it to make work for me. [http://stackoverflow.com/questions/30544209/why-does-my-dialogue-box-not-show-when-fullscr-true] (http://stackoverflow.com/questions/30544209/why-does-my-dialogue-box-not-show-when-fullscr-true)

What specifically went wrong when you tried that?:
There is no error, but the screen is ‘stuck’ on the preceding routine, but the dialogue box appears behind this routine which is still in full screen, and I only can access it through Task Manager.

When fullscreen is true every other window of the computer is always obscured. That is ideal for timing because your computer can stop processing all the other windows. Switch out of fullscreen mode (in Builder experiments that’s in the Experiment Settings dialog) to allow a dialog to be presented but your timing won’t be quite as good.

For the purpose of my experiment, there is no necessity for perfect timing, so switching off full screen helped - the dialogue box is visible! Thank you!

But now the dialogue box appears in the preceding routine (description), but has to appear at the next one (dialoguebox). I put a white picture as a background at the same routine as the code for the dialogue box and response (any key) in dialoguebox routine. Should I move my code component in a different place/order?

No idea why it appears during description. Maybe description is just too quick and so it proceeds straight to next routine?

I decided to leave the dialogue box in “description”.Deleted the white background picture and response in “dialoguebox” routine and it worked perfectly.

Thank you for quick responses!

I’m still working on this code… I’ve got an issue regarding saving the data from the dialogue boxes:

  • I have 6 different loops with 100 trials each.

  • After each loop, there is a dialogue window that asks participants to give some information about their experience in the finished loop.

  • I use this code for the dialogue box to appear:

info = {'Green Deck: you got 4 poitns in %':'', 
         'Purple Deck: you got 30 points in %':'',
         'Purple Deck: you got 0 points in %':''}
dictDlg = gui.DlgFromDict(dictionary=info,
          title='Your description of the task', fixed=['ExpVersion'])
if dictDlg.OK:
    info = dictDlg.data[0]
    print (info)
    continueRotuine =False

else:
    print('User Cancelled')
    continueRotuine =False

The dialogue window appears when it supposed to and disappears after participant clicks OK and experiment proceeds with the next loop. But, data from the dialogue window are not stored in the final data spreadsheet. Do I miss anything in my code to make it store the data?

Also, the data from the whole experiment looks as a mess (for now I have only two trials for each loop). How can I customise it? And get rid of all the unnecessary columns?

Sorry, I’m mixing up the topics, but I thought there is no point to open up a new one.
Hope to hear some advice on this.
Thank you!