Bug introduced in new versions: Dialog box blocks event.waitKeys

At some point after version 2023.2.3, the dialog functionality started blocking the calls from ‘event.waitKeys’. This is a minimal example:

from psychopy import visual, event, core, gui

win = visual.Window()

dlg = gui.Dlg() # Issue is solved by commenting this line

text = visual.TextStim(win, 'Text')

text.draw()
win.flip()

event.waitKeys()
# No event is registered here

core.quit()

Thank you,
Martin

A git bisect on this bug (using the minimal example above) shows that the bug was introduced in the following commit: a4d405ba3d5832e83376c76dfac89fe884a722e5

I’m not able to replicate this bug in 2024.2.4 (Windows).

I’m not a coder expert so it took me a while to work out why I wasn’t seeing a dialogue box

The following gives me a box and accepts a key to end

from psychopy import visual, event, core, gui
win = visual.Window()

dlg = gui.Dlg() # Issue is solved by commenting this line
dlg.show()

text = visual.TextStim(win, 'Text')

text.draw()
win.flip()

event.waitKeys()
# No event is registered here

core.quit()

Thanks for the reply. To add context, I’m using Mac. Here are some details:

  • Chip: Apple M1 Pro
  • macOS: 14.6.1 (23G93)
  • pyQt version: PyQt6
    • Qt: v 5.15.2 PyQt: v 5.15.9
  • glfw version: 2.5.5
  • pyglet version: 1.5.27
  • python version: 3.9.16

Looking at the notes for RF: Rework glfw support in the event module. · psychopy/psychopy@a4d405b · GitHub

I wonder if the issue is

Remove an extra event pump in waitKeys-- unnecessary
if getKeys already pumps events?

Maybe it is necessary on Macs

What happens if you have an event.getKeys() loop instead?

from psychopy import visual, event, core, gui
win = visual.Window()

dlg = gui.Dlg() # Issue is solved by commenting this line
dlg.show()

text = visual.TextStim(win, 'Text')

text.draw()
win.flip()

#event.waitKeys()
# No event is registered here
while not event.getKeys():
    core.wait(.01)

core.quit()