Dialog box empty text prevent

Hi,
I am looking for find prevent empty text input for the participant name. I try with regexp in the dialog, but i have no idea how to manage the problem.
please help.

regards,
tomasz

So you just want to make sure the text isn’t blank? Or you want no trailing or extra blank characters?

If you meant the first:

infoDict = {'Name:': '', 'Attempt:': ''}
while not infoDict['Name:']:
    dlg = DlgFromDict(dictionary=infoDict)

Or if you meant removing all spaces, check this answer on stack overflow:

http://stackoverflow.com/questions/8270092/python-remove-all-whitespace-in-a-string

infoDict['Name:'] = infoDict['Name:'].replace(" ", "")
1 Like

Hi Daniel,
thank you for the answer.
With the standard settings of the info dialog box, the participant name can be empty. I wold like to force the participants for the name. this is my problem.

with regards,
tomasz

OK great, my first example shows an example of how to do this. You are using the coder, and not the builder, correct?

Hi Daniel,
yes:) now if fine thank you.
BTW, do you known how to see the dialog box bigger then standard one, please?

with regards,
tomasz

Hello Tomasz,

Instead of using DlgFromDict, you would have to use the slightly more involved Dlg() and pass the ‘size’ argument when you create it, see the docs for an example:

http://www.psychopy.org/api/gui.html

Hello,
there is problem. I checked code like this:
rom psychopy import gui

myDlg = gui.Dlg(title=“My experiment”,size=(800,600))

ok_data = myDlg.show()

but the window was still small :frowning: maybe I did something wrong?

with regards,
tomasz

Hello @daniel.riggs1, @tomaszkaczorek,

I intend to use the first code.
\
infoDict = {‘Name:’: ‘’, ‘Attempt:’: ‘’}
while not infoDict[‘Name:’]:
dlg = DlgFromDict(dictionary=infoDict)
\\

But I could not figure out where to insert this code? Please help.

It’s been four years so I’m not sure how much has changed, but if you’re using the builder this would go in a code component.

Hello @daniel.riggs1,

Sorry for not noticing the timeline of this thread. Fortunately, I was able to work around this issue using another process. Thanks anyway :slight_smile:

1 Like