Why Does My Dialogue Box Not Show When Fullscr=true?
I want to display a dialogue box to ask an experimental participant to enter a number, using psychopy. When fullscr=False in win, the dialogue box displays. When fullscr=True, it d
Solution 1:
This is because the psychopy window is on top of everything else when fullscr=True
so in your example, the dialogue box is created but not visible to the user since the window is on top.
Present dialogue box in the beginning
If you just want a dialogue box in the beginning of the experiment, the solution is easy: show the dialogue box before creating the window:
# Import stufffrom psychopy import visual, gui
# Show dialogue box
respInfo={'duration': ''}
respDlg = gui.DlgFromDict(respInfo)
# Initiate window
win = visual.Window(fullscr=True)
Present dialogue box mid-way
You need a pretty convoluted hack if you want to show a dialogue midway during the experiment. You need to
- close your current window,
- show the dialogue box (optionally with a non-fullscreen window in the background to cover up your desktop)
- create a new window (and close the optional window from step 2
- set all stimuli to be rendered in the new window. Since the stimuli are pointing to the first window object, just creating a new window (new object) with the same variable name won't do the trick.
Here's some code that demos this approach with a single stimulus:
# Import stuff, create a window and a stimulusfrom psychopy import visual, event, gui
win1 = visual.Window(fullscr=True)
stim = visual.TextStim(win1) # create stimulus in win1# Present the stimulus in window 1
stim.draw()
win1.flip()
event.waitKeys()
# Present dialogue box
win_background = visual.Window(fullscr=False, size=[5000, 5000], allowGUI=False) # optional: a temporary big window to hide the desktop/app to the participant
win1.close() # close window 1
respDict = {'duration':''}
gui.DlgFromDict(respDict)
win_background.close() # clean up the temporary background # Create a new window and prepare the stimulus
win2 = visual.Window(fullscr=True)
stim.win = win2 # important: set the stimulus to the new window.
stim.text = 'entered duration:' + respDict['duration'] # show what was entered# Show it!
stim.draw()
win2.flip()
event.waitKeys()
Post a Comment for "Why Does My Dialogue Box Not Show When Fullscr=true?"