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

TypeError: unsupported operand type(s) for &: 'int' and 'KeyboardModifier' for PySide6 #1004

Open
markasbach opened this issue Oct 20, 2022 · 1 comment

Comments

@markasbach
Copy link

We are using enable together with chaco and traits in PySide6 application with Python 3.10. On both macOS and Windows, stderr gets flooded with TypeError from BaseWindow._create_mouse_event():

Traceback (most recent call last):
  File "enable\qt4\base_window.py", line 270, in leaveEvent
  File "enable\qt4\base_window.py", line 148, in leaveEvent
  File "enable\abstract_window.py", line 349, in _handle_mouse_event
  File "enable\qt4\base_window.py", line 515, in _create_mouse_event
TypeError: unsupported operand type(s) for &: 'int' and 'KeyboardModifier'

The respective code reads alt_down=bool(modifiers & QtCore.Qt.AltModifier), and it seems that the problem is that many enums from the current PySide6 implementation do not automatically convert to int.

It could be sufficient to use .value() to get the int value just like this:

alt_down=bool(modifiers & QtCore.Qt.AltModifier.value),

These are the versions we use:

  • PySide6==6.4.0
  • enable==5.3.1
  • Python 3.10.8
@mdickinson
Copy link
Member

Thanks for the report. Unfortunately, PySide 6.4.0 changed a lot of enums in a backwards incompatible way, and it's going to take us a while to fix all the resulting damage in ETS. If you can, I'd suggest pinning PySide 6 to a version older than 6.4 for the time being.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants