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' when running enable/enable/examples/demo/enable/basic_draw with python3.11 #1030

Closed
homosapien-lcy opened this issue Apr 17, 2023 · 0 comments · Fixed by #1045

Comments

@homosapien-lcy
Copy link
Contributor

Problem Description
When running many enable examples such as enable/enable/examples/demo/enable/basic_draw.py, the example will run successfully at first but the plot will disappear after clicking other parts of the screen. Then the following error message will show up in the terminal after closing the plot window:

(py311) (base) cyliu@aus552cyliu 3.11_test % python3.11 enable/enable/examples/demo/enable/basic_draw.py
2023-04-17 12:46:55.990 Python[5078:122981] 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/enable/enable/examples/demo/enable/basic_draw.py", line 42, in <module>
    demo = demo_main(Demo)
           ^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/enable/enable/examples/_example_support.py", line 40, in demo_main
    demo_class().configure_traits()
  File "/Users/cyliu/Documents/3.11_test/traits/traits/has_traits.py", line 2163, in configure_traits
    rc = toolkit().view_application(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt4/toolkit.py", line 237, in view_application
    return view_application.view_application(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt4/view_application.py", line 92, in view_application
    return ViewApplication(
           ^^^^^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt4/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/qt4/toolkit.py", line 129, in eventFilter
    if event.type() == QtCore.QEvent.Type.KeyPress:
       ^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt4/toolkit.py", line 129, in eventFilter
    if event.type() == QtCore.QEvent.Type.KeyPress:
       ^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt4/toolkit.py", line 129, in eventFilter
    if event.type() == QtCore.QEvent.Type.KeyPress:
       ^^^^^^^^^^^^
  [Previous line repeated 4 more times]
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt4/ui_base.py", line 175, in closeEvent
    if self._ok_to_close():
       ^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt4/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/qt4/toolkit.py", line 129, in eventFilter
    if event.type() == QtCore.QEvent.Type.KeyPress:
       ^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt4/toolkit.py", line 129, in eventFilter
    if event.type() == QtCore.QEvent.Type.KeyPress:
       ^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt4/toolkit.py", line 129, in eventFilter
    if event.type() == QtCore.QEvent.Type.KeyPress:
       ^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/enable/enable/qt4/base_window.py", line 255, in paintEvent
    self.handler.paintEvent(event)
  File "/Users/cyliu/Documents/3.11_test/enable/enable/qt4/base_window.py", line 90, in paintEvent
    self._enable_window._paint(event)
  File "/Users/cyliu/Documents/3.11_test/enable/enable/abstract_window.py", line 524, in _paint
    size = self._get_control_size()
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/enable/enable/qt4/base_window.py", line 600, in _get_control_size
    return (int(self.control.width() * self.base_pixel_scale),
                ^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt4/toolkit.py", line 129, in eventFilter
    if event.type() == QtCore.QEvent.Type.KeyPress:
       ^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt4/toolkit.py", line 129, in eventFilter
    if event.type() == QtCore.QEvent.Type.KeyPress:
       ^^^^^^^^^^^^
  File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/traitsui/qt4/toolkit.py", line 129, in eventFilter
    if event.type() == QtCore.QEvent.Type.KeyPress:
       ^^^^^^^^^^^^
  [Previous line repeated 1 more time]
  File "/Users/cyliu/Documents/3.11_test/enable/enable/qt4/base_window.py", line 270, in leaveEvent
    self.handler.leaveEvent(event)
  File "/Users/cyliu/Documents/3.11_test/enable/enable/qt4/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/qt4/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.

Reproduction Steps:

python enable/enable/examples/demo/enable/basic_draw.py

Then click away and close the plot window

Expected behavior:
The program successfully run and no error message after closing

OS, Python version:
[MacOS, python 3.11]

Package list:
Package Version Editable project location


attrdict 2.0.1
attrdict3 2.0.2
chaco 5.1.0 /Users/cyliu/Documents/3.11_test/chaco
configobj 5.0.8
enable 5.4.0.dev28 /Users/cyliu/Documents/3.11_test/enable
fonttools 4.39.2
joblib 1.2.0
numpy 1.24.2
pandas 1.5.3
Pillow 9.4.0
pip 22.3.1
PyAudio 0.2.13
pyface 8.0.0
pygarrayimage 1.0
pyglet 2.0.5 /Users/cyliu/Documents/3.11_test/pyglet
Pygments 2.14.0
pyparsing 3.0.9
PySide6 6.4.3
PySide6-Addons 6.4.3
PySide6-Essentials 6.4.3
python-dateutil 2.8.2
pytz 2023.2
reportlab 3.6.12
scikit-learn 1.2.2
scipy 1.10.1
setuptools 65.6.3
shiboken6 6.4.3
six 1.16.0
threadpoolctl 3.1.0
traits 7.0.0.dev1840 /Users/cyliu/Documents/3.11_test/traits
traitsui 7.4.3
wxPython 4.2.0

@homosapien-lcy homosapien-lcy changed the title TypeError: unsupported operand type(s) for &: 'int' and 'KeyboardModifier' TypeError: unsupported operand type(s) for &: 'int' and 'KeyboardModifier' when running enable/enable/examples/demo/enable/basic_draw Apr 21, 2023
@homosapien-lcy homosapien-lcy changed the title TypeError: unsupported operand type(s) for &: 'int' and 'KeyboardModifier' when running enable/enable/examples/demo/enable/basic_draw TypeError: unsupported operand type(s) for &: 'int' and 'KeyboardModifier' when running enable/enable/examples/demo/enable/basic_draw with python3.11 Apr 21, 2023
corranwebster added a commit that referenced this issue May 15, 2023
This PR:
- removes some remaining OpenGL code that is no longer used
- cleans up the logic around the creation of mouse events and drag events

This is a follow-up to some of the issues identified in #1030
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

Successfully merging a pull request may close this issue.

1 participant