psychopy.org | Reference | Downloads | Github

Dialog boxes and fullscr windows

fullscr
dialog
screen

#1

People have often asked about how to present a dialog box when using windows with fullscr=True and we’ve always pointed out that this is actually a feature of the the fullscreen mode that the dialog isn’t visible.
Previous workarounds have involved getting the screen out of fullscreen mode but I’ve been playing with this a little today and it looks like the easiest possible workaround is to make the window invisible without it ever changing from fullscr=True!

This demo script shows that working:

from psychopy import visual, gui, core

win = visual.Window([1024,768], fullscr = True)
msg = visual.TextStim(win, 'this is full-screen mode (good timing)',color='white')

msg.draw()
win.flip()
core.wait(1)

win.winHandle.set_visible(False)

info={'what do you think?':''}
dlg = gui.DlgFromDict(info)

win.winHandle.set_visible(True)

msg.text = "you said:" + info['what do you think?']
msg.draw()
win.flip()  # after being invisible we do need a flip again
core.wait(1)

Gui controls with callback functions
#2

thx @jon!
There is a tiny little mistake in your example script, though:
in line msg.text = "you said:" + info['what do you think? '], there is a space after the question mark leading to a KeyError.


#3

thanks mario, I’ve edited that to fix the error


#4

Thanks Jon! Do you know what the equivalent to this work-around would be inside Builder?


#5

You would need a code component with this in the place that you need it:

win.winHandle.set_visible(False)

info={'what do you think?':''}
dlg = gui.DlgFromDict(info)

win.winHandle.set_visible(True)

#6

Hi Jon,

Just a bit of feedback from Mac versions 1.84 and 1.85.
I tried running this on macOS Sierra 10.12.4. When win.winHandle.set_visible(False) is run, all I get is a black screen. I’m not sure if this is a quirk of the OS, disabling access to the GPU for all background apps automatically to ensure good performance. When Fullscr = False it works fine.

Best wishes,

Oli


#7

Oli you’re right. On Mac it looks like we have to get out of fullscreen mode first:

...
win.winHandle.set_fullscreen(False)
win.winHandle.set_visible(False)

info={'what do you think?':''}
dlg = gui.DlgFromDict(info)

win.winHandle.set_visible(True)
win.winHandle.set_fullscreen(True)
...

Then the other annoyance is that it seems to create a new context that hasn’t got our settings applied (like the background colour). Looks like we need to implement our own function Window.setVisible(True/False) that handles these extra things. Almost certainly it means that all stimuli will need redrawing when the screen returns.