enable icon indicating copy to clipboard operation
enable copied to clipboard

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

Open markasbach opened this issue 3 years ago • 1 comments

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

markasbach avatar Oct 20 '22 14:10 markasbach

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.

mdickinson avatar Oct 24 '22 07:10 mdickinson