Hi, looks like one of the recent versions broke some of the gui.DLG functionality I have long been using, at least on MacOS (Sonoma 14.6).
It seems the dictionary returned by dlg.show() no longer is in the same format, yielding the keyError shown if you execute the code I have pasted at bottom.
Moreover, while the result of my code used to give a dialog box that looks like this:
It now looks like this, with none of the question text showing any more:
from psychopy import gui
# Collect demographic variables
# Use a gui.Dlg and so you can avoid labeling the cancel button , but can't avoid showing it
# This approach gives more control, eg, text color.
questions = ['What is your age?', 'Which of the following best describes your gender?', 'What is the first language you learned to read?', 'Are you fluent in English?']
dlg = gui.Dlg(title="PatHons", labelButtonOK=u' OK ', labelButtonCancel=u'', pos=(200, 400)) # Cancel (decline to answer all)
dlg.addField(questions[0])
dlg.addField(questions[1], choices=[ 'Man','Woman','Trans and/or gender diverse','I use a different term','Decline to answer'])
dlg.addField(questions[2], choices=[ 'English','Arabic','Pali','Hebrew','Farsi','Chinese','Korean','Japanese','Other','Decline to answer'])
dlg.addField(questions[3], choices=[ 'Yes','No','Decline to answer'])
thisInfo = dlg.show() # you have to call show() for a Dlg (automatic with a DlgFromDict)
demographics = {q: 'Decline to answer (pressed unlabeled cancel button)' for q in questions} #Assume pressed cancel unless get values
if dlg.OK:
print(thisInfo)
print( "type of thisInfo=", type(thisInfo), "dir=",dir(thisInfo) )
print("I think this works prior to 2024.1.5, but now gives a KeyError:", thisInfo[0] )
demographics = dict([ (questions[0], thisInfo[0]), (questions[1], thisInfo[1]), (questions[2], thisInfo[2]), (questions[3], thisInfo[3])])
#end demographics collection
I’m not sure when between 2023.2.3 and 2024.1.5 it broke (it’s also broken in 2024.2.1).