enthought / chaco

Chaco is a Python package for building interactive and custom 2-D plots.
http://docs.enthought.com/chaco/
Other
292 stars 99 forks source link

TypeError: unsupported operand type(s) for &: 'int' and 'KeyboardModifier' when running multiple tests on python 3.11 or 3.8 not using the EDM environment when running python chaco/examples/demo/multiaxis_using_Plot.py #863

Open homosapien-lcy opened 1 year ago

homosapien-lcy commented 1 year ago

Problem Description When running multiple demos using python 3.11 or 3.8 (without EDM), a TypeError: unsupported operand type(s) for &: 'int' and 'KeyboardModifier' will occur after closing the plot window

Reproduction Steps: python chaco/examples/demo/multiaxis_using_Plot.py

Expected behavior: Plot a multiple axis plot without error.

OS, Python version: [MacOS, python 3.11 or python 3.8 (without EDM, the example will pass on EDM)]

dpinte commented 1 year ago

@mdickinson Is this something that should be fixed by the recent compatibility of TraitsUI with the latest PySide 6?

corranwebster commented 1 year ago

Can you please try running these with current main branch Pyface and TraitsUI to see if these have been fixed, ie. do:

pip install --force-reinstall git+http://github.com/enthought/pyface.git
pip install --force-reinstall git+http://github.com/enthought/traitsui.git

and then try the failing tests. Several errors like this were fixed in Pyface recently.

homosapien-lcy commented 1 year ago

http://github.com/enthought/pyface.git

Hi Corran:

I installed the latest Pyface and TraitsUI, here is the version that is printed out: traitsui.version 8.0.0.dev0 pyface.version 7.4.4

However, the same error still occurs in many demos such as:

chaco/examples/demo/domain_limits.py chaco/examples/demo/depth.py

dpinte commented 1 year ago

@homosapien-lcy can you test this again with the latest pyface and traitsui?

homosapien-lcy commented 1 year ago

@homosapien-lcy can you test this again with the latest pyface and traitsui?

The error remains after I reinstalled these two packages with the following command:

python3.11 pip install --force-reinstall git+http://github.com/enthought/pyface.git
python3.11 -m pip install --force-reinstall git+http://github.com/enthought/traitsui.git

Then I ran

python3.11 examples/demo/financial_plot_dates.py

and if I click one the plot and close it, the same error will happen.

(py311) (base) cyliu@aus552cyliu chaco % python3.11 examples/demo/financial_plot_dates.py
2023-04-26 11:48:12.283 Python[4618:92403] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/2z/kylzj9s92y71cxscmljmpqrh0000gt/T/org.python.python.savedState
Traceback (most recent call last):
  File "/Users/cyliu/Documents/3.11_test/chaco/examples/demo/financial_plot_dates.py", line 189, in <module>
    demo.configure_traits()
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traits/has_traits.py", line 2164, in configure_traits
    rc = toolkit().view_application(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt/toolkit.py", line 237, in view_application
    return view_application.view_application(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt/view_application.py", line 92, in view_application
    return ViewApplication(
           ^^^^^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt/view_application.py", line 138, in __init__
    start_event_loop_qt4()
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/pyface/util/guisupport.py", line 156, in start_event_loop_qt4
    app.exec()
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt/toolkit.py", line 129, in eventFilter
    if event.type() == QtCore.QEvent.Type.KeyPress:
       ^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt/toolkit.py", line 129, in eventFilter
    if event.type() == QtCore.QEvent.Type.KeyPress:
       ^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt/toolkit.py", line 129, in eventFilter
    if event.type() == QtCore.QEvent.Type.KeyPress:
       ^^^^^^^^^^^^
  [Previous line repeated 6 more times]
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt/ui_base.py", line 175, in closeEvent
    if self._ok_to_close():
       ^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt/ui_base.py", line 228, in _ok_to_close
    is_ok = not self.isModal()
                ^^^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt/toolkit.py", line 129, in eventFilter
    if event.type() == QtCore.QEvent.Type.KeyPress:
       ^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt/toolkit.py", line 129, in eventFilter
    if event.type() == QtCore.QEvent.Type.KeyPress:
       ^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt/toolkit.py", line 129, in eventFilter
    if event.type() == QtCore.QEvent.Type.KeyPress:
       ^^^^^^^^^^^^
  [Previous line repeated 54 more times]
  File "/Users/cyliu/Documents/3.11_test/enable/enable/qt/base_window.py", line 270, in leaveEvent
    self.handler.leaveEvent(event)
  File "/Users/cyliu/Documents/3.11_test/enable/enable/qt/base_window.py", line 148, in leaveEvent
    self._enable_window._handle_mouse_event("mouse_leave", event)
  File "/Users/cyliu/Documents/3.11_test/enable/enable/abstract_window.py", line 349, in _handle_mouse_event
    mouse_event = self._create_mouse_event(event)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/enable/enable/qt/base_window.py", line 515, in _create_mouse_event
    alt_down=bool(modifiers & QtCore.Qt.AltModifier),
                  ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for &: 'int' and 'KeyboardModifier'
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.
    Note: This exception was delayed.

Indeed, the latest commit in traitsui is on 4/17 (https://github.com/enthought/traitsui/commits/main) and pyface on 4/6 (https://github.com/enthought/pyface/commits/main), and I don't they are related to this problem