enthought / traitsui

TraitsUI: Traits-capable windowing framework
http://docs.enthought.com/traitsui
Other
295 stars 95 forks source link

QEvent.Type error seen on Windows 10 + Python 3.8 + PyQt6 backend #1926

Open mgrady3 opened 1 year ago

mgrady3 commented 1 year ago

While testing the latest trauitsUI on Python 3.8 using the PyQt6 backend (all provided via EDM), I see the following traceback (truncated to just the part with the relevant line):

...

 _QT_TRAITS_EVENT = QtCore.QEvent.Type(QtCore.QEvent.registerEventType())
  File "C:\Users\<myuser>\.edm\envs\<my_env>\lib\enum.py", line 339, in __call__
    return cls.__new__(cls, value)
  File "C:\Users\<my_user>\.edm\envs\<my_env>\lib\enum.py", line 663, in __new__
    raise ve_exc
ValueError: 65534 is not a valid Type

The above stems from this line in traitsui: https://github.com/enthought/traitsui/blob/main/traitsui/qt4/toolkit.py#L49

corranwebster commented 1 year ago

Looks like the PyQt6 invocation is QEvent(QEvent.registerEventType()) (see https://www.riverbankcomputing.com/pipermail/pyqt/2022-January/044476.html)

joshduran commented 1 year ago

I am experiencing the same issue. Simply having PyQt6 installed alongside traitsui will trigger this error as soon as you attempt:

from traitsui.api import View

I am also using Windows 10 64-bit, Python 3.8 with pyqt6 and traitsui installed via edm

It seems like under traitsui > qt4 > toolkit.py:

line 49: _QT_TRAITS_EVENT = QtCore.QEvent.Type(QtCore.QEvent.registerEventType())

should be changed to: _QT_TRAITS_EVENT = QtCore.QEvent(QtCore.QEvent.registerEventType())

However, I do not know if this would cause other problems for older versions of pyqt, such as PyQt5 that is used with python 3.6?

corranwebster commented 1 year ago

Thanks for the information - we currently don't have full support for PyQt6 - Pyface should work, but I don't think we made all the changes needed for PyQt6.

So if you need Qt6, PySide < 6.4 is the current recommendation.

Hopefully we will have time to update to most recent Qt6 wrappers in the next month or two.