Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Dlg example raises an exception #6373

Open
hoechenberger opened this issue Apr 14, 2024 · 2 comments
Open

[Bug]: Dlg example raises an exception #6373

hoechenberger opened this issue Apr 14, 2024 · 2 comments
Labels
🐞 bug Issue describes a bug (crash or error) or undefined behavior.

Comments

@hoechenberger
Copy link
Contributor

hoechenberger commented Apr 14, 2024

PsychoPy Version

v2024.1.1 stand-alone

What OS are your PsychoPy running on?

macOS Silicon

Bug Description

I tried to run the Dlg example

from psychopy import gui

myDlg = gui.Dlg(title="JWP's experiment")
myDlg.addText('Subject info')
myDlg.addField('Name:')
myDlg.addField('Age:', 21)
myDlg.addText('Experiment Info')
myDlg.addField('Grating Ori:',45)
myDlg.addField('Group:', choices=["Test", "Control"])
ok_data = myDlg.show()  # show dialog and wait for OK or Cancel
if myDlg.OK:  # or if ok_data is not None
    print(ok_data)
else:
    print('user cancelled')

Raises an exception:

Traceback (most recent call last):
  File "/Users/richardhochenberger/Library/CloudStorage/[redacted]", line 6, in <module>
    myDlg.addField('Age:', 21)
  File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/gui/qtgui.py", line 252, in addField
    inputLabel = self.addText(label, color, isFieldLabel=True)
  File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/gui/qtgui.py", line 219, in addText
    textLabel = QtWidgets.QLabel(text, parent=self)
TypeError: arguments did not match any overloaded call:
  QLabel(parent: typing.Optional[QWidget] = None, flags: Union[Qt.WindowFlags, Qt.WindowType] = Qt.WindowFlags()): argument 1 has unexpected type 'int'
  QLabel(text: str, parent: typing.Optional[QWidget] = None, flags: Union[Qt.WindowFlags, Qt.WindowType] = Qt.WindowFlags()): argument 1 has unexpected type 'int'
################ Experiment ended with exit code 1 [pid:95417] #################

Expected Behaviour

A dialog should display.

Steps to Reproduce

  1. Paste example code into Coder.
  2. Save file.
  3. Run.

Additional context

Documentation bug, I'd say
I'm using DlgFromDict instead now, which seems to be working fine.

@hoechenberger hoechenberger added the 🐞 bug Issue describes a bug (crash or error) or undefined behavior. label Apr 14, 2024
@Cortexan
Copy link

Cortexan commented Apr 15, 2024

I noticed this same issue; it was resolved by explicitly setting the key and label arguments when adding fields e.g.:

# New version (PsychoPy >= 2023.2)
subjData = gui.Dlg(title="Auszogne - Settings",
                   screen=-1,
                   alwaysOnTop=True)

# [0]
subjData.addField(key = 0,
                  label = 'Subject:',
                  initial = 0)
# [1]
subjData.addField(key = 1,
                  label = 'Screen:',
                  initial = 'Lab',
                  choices = ['Lab', 'Laptop', 'Home', 'Home2'])
# [2]
subjData.addField(key = 2,
                  label = 'Fullscreen:',
                    initial = True)
# [3]
subjData.addField(key = 3,
                  label = 'Cue(s):',
                  initial='Audio',
                  choices=['Visual', 'Audio', 'Both'])

# [4]
subjData.addField(key = 4,
                  label = 'Colour Set:',
                  initial='New',
                  choices=['New', 'Old'])

subjData.show()
if not subjData.OK:
    core.quit()

@michalrzak
Copy link

I think this would get fixed by #6335. The problem is the diverging implementation of the dialogue boxes in QT and WX.

The example from the wiki would work fine on the QT backend, whereas it fails on the WX backend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Issue describes a bug (crash or error) or undefined behavior.
Projects
None yet
Development

No branches or pull requests

3 participants