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

NotImplementedError when running examples/demo/updating_plot/updating_plot1.py #896

Open homosapien-lcy opened 1 year ago

homosapien-lcy commented 1 year ago

Problem Description When running examples/demo/updating_plot/updating_plot1.py, a NotImplementedError will be raised. It seems that this error comes from enable/enable/examples/_example_support.py and the _create_component is left unimplemented. If this is deliberately left unimplemented then no fix is needed.

Reproduction Steps:

python  examples/demo/updating_plot/updating_plot1.py

Full Stacktrace:

(py311) (base) cyliu@aus552cyliu chaco % python3.11 examples/demo/updating_plot/updating_plot1.py
/Users/cyliu/Documents/3.11_test/chaco/examples/demo/updating_plot/updating_plot1.py:20: DeprecationWarning: This module is meant for internal use only and it is not meant for use in library code. Importing from this module is deprecated and it will be removed in Enable 6.0. We highly recommend that you update your code and vendorize what is necessary.
  from enable.example_support import DemoFrame, demo_main
Traceback (most recent call last):
  File "/Users/cyliu/Documents/3.11_test/chaco/examples/demo/updating_plot/updating_plot1.py", line 87, in <module>
    demo = demo_main(PlotFrame, size=(600, 500), title="Simple line plot")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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/.venvs/py311/lib/python3.11/site-packages/traits/has_traits.py", line 2164, in configure_traits
    rc = toolkit().view_application(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/toolkit.py", line 237, in view_application
    return view_application.view_application(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/view_application.py", line 92, in view_application
    return ViewApplication(
           ^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/view_application.py", line 127, in __init__
    self.ui = self.view.ui(
              ^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/view.py", line 457, in ui
    ui.ui(parent, kind)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/ui.py", line 234, in ui
    self.rebuild(self, parent)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/toolkit.py", line 168, in ui_live
    ui_live.ui_live(ui, parent)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_live.py", line 52, in ui_live
    _ui_dialog(ui, parent, BaseDialog.NONMODAL)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_live.py", line 72, in _ui_dialog
    BaseDialog.display_ui(ui, parent, style)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_base.py", line 294, in display_ui
    ui.owner.init(ui, parent, style)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_live.py", line 231, in init
    self.add_contents(panel(ui), bbox)
                      ^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_panel.py", line 270, in panel
    panel = _GroupPanel(content[0], ui).control
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_panel.py", line 621, in __init__
    layout = self._add_items(content, inner)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_panel.py", line 855, in _add_items
    editor = factory_method(
             ^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/editor_factory.py", line 117, in simple_editor
    return self.simple_editor_class(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/editor.py", line 540, in __init__
    self.old_value = getattr(self.object, self.name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/enable/enable/examples/_example_support.py", line 31, in _component_default
    return self._create_component()
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/enable/enable/examples/_example_support.py", line 36, in _create_component
    raise NotImplementedError
NotImplementedError

Links: https://github.com/enthought/chaco/blob/main/examples/demo/updating_plot/updating_plot1.py https://github.com/enthought/enable/blob/main/enable/examples/_example_support.py#L33

OS, Python version: [MacOS, python3.11]

Package Version


altgraph 0.17.2 autopep8 2.0.1 boto3 1.26.50 botocore 1.29.50 camelot-py 0.10.1 certifi 2022.12.7 cffi 1.15.1 chaco 5.1.0 chardet 5.1.0 charset-normalizer 3.1.0 click 8.1.3 contourpy 1.0.7 cPython 0.0.6 cryptography 39.0.0 cycler 0.11.0 Cython 0.29.33 distro 1.8.0 dnspython 2.3.0 enable 5.3.1 et-xmlfile 1.1.0 examples 1.0.2 fonttools 4.39.0 future 0.18.2 idna 3.4 importlib-metadata 6.6.0 importlib-resources 5.12.0 install 1.3.5 isort 5.12.0 jmespath 1.0.1 kiwisolver 1.4.4 macholib 1.15.2 matplotlib 3.7.1 numpy 1.24.1 opencv-python 4.7.0.68 openpyxl 3.0.10 packaging 23.0 pandas 1.5.2 pdfminer.six 20221105 Pillow 9.3.0 pip 21.2.4 pycodestyle 2.10.0 pycparser 2.21 pydantic 1.10.7 pyface 8.0.0 pymongo 4.3.3 PyMuPDF 1.21.1 pyparsing 3.0.9 PyPDF2 2.12.1 PyQt5 5.15.9 PyQt5-Qt5 5.15.2 PyQt5-sip 12.11.1 PySide6 6.4.2 PySide6-Addons 6.4.2 PySide6-Essentials 6.4.2 python-dateutil 2.8.2 pytz 2022.7.1 requests 2.28.2 s3transfer 0.6.0 scipy 1.10.1 setuptools 58.0.4 shiboken6 6.4.2 six 1.15.0 tabula-py 2.6.0 tabulate 0.9.0 textract-trp 0.1.3 tomli 2.0.1 traits 6.4.1 traitsui 7.4.3 typing_extensions 4.4.0 urllib3 1.26.15 vtk 9.2.6 wheel 0.37.0 zipp 3.15.0

homosapien-lcy commented 1 year ago

I think this is not as easy to fix as we think... after replacing _create_window with _create_component, a 'PySide6.QtWidgets.QWidget.init' called with wrong argument type error will be raised.

(py311) (base) cyliu@aus552cyliu chaco % python3.11 examples/demo/updating_plot/updating_plot1.py
/Users/cyliu/Documents/3.11_test/chaco/examples/demo/updating_plot/updating_plot1.py:20: DeprecationWarning: This module is meant for internal use only and it is not meant for use in library code. Importing from this module is deprecated and it will be removed in Enable 6.0. We highly recommend that you update your code and vendorize what is necessary.
  from enable.example_support import DemoFrame, demo_main
Traceback (most recent call last):
  File "/Users/cyliu/Documents/3.11_test/chaco/examples/demo/updating_plot/updating_plot1.py", line 87, in <module>
    demo = demo_main(PlotFrame, size=(600, 500), title="Simple line plot")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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/.venvs/py311/lib/python3.11/site-packages/traits/has_traits.py", line 2164, in configure_traits
    rc = toolkit().view_application(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/toolkit.py", line 237, in view_application
    return view_application.view_application(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/view_application.py", line 92, in view_application
    return ViewApplication(
           ^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/view_application.py", line 127, in __init__
    self.ui = self.view.ui(
              ^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/view.py", line 457, in ui
    ui.ui(parent, kind)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/ui.py", line 234, in ui
    self.rebuild(self, parent)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/toolkit.py", line 168, in ui_live
    ui_live.ui_live(ui, parent)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_live.py", line 52, in ui_live
    _ui_dialog(ui, parent, BaseDialog.NONMODAL)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_live.py", line 72, in _ui_dialog
    BaseDialog.display_ui(ui, parent, style)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_base.py", line 294, in display_ui
    ui.owner.init(ui, parent, style)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_live.py", line 231, in init
    self.add_contents(panel(ui), bbox)
                      ^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_panel.py", line 270, in panel
    panel = _GroupPanel(content[0], ui).control
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_panel.py", line 621, in __init__
    layout = self._add_items(content, inner)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_panel.py", line 855, in _add_items
    editor = factory_method(
             ^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/editor_factory.py", line 117, in simple_editor
    return self.simple_editor_class(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/editor.py", line 540, in __init__
    self.old_value = getattr(self.object, self.name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/enable/enable/examples/_example_support.py", line 31, in _component_default
    return self._create_component()
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/chaco/examples/demo/updating_plot/updating_plot1.py", line 66, in _create_component
    return Window(self, -1, component=plot)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/enable/enable/qt/base_window.py", line 373, in __init__
    self.control = self._create_control(parent, self)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/enable/enable/qt/base_window.py", line 651, in _create_control
    return _QtWindow(parent, enable_window)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/enable/enable/qt/base_window.py", line 244, in __init__
    super().__init__(parent)
TypeError: 'PySide6.QtWidgets.QWidget.__init__' called with wrong argument types:
  PySide6.QtWidgets.QWidget.__init__(PlotFrame)
Supported signatures:
  PySide6.QtWidgets.QWidget.__init__(Optional[PySide6.QtWidgets.QWidget] = None, PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags))

Same for examples/demo/canvas/canvas.py

(py311) (base) cyliu@aus552cyliu chaco % python3.11 examples/demo/canvas/canvas.py 
/Users/cyliu/Documents/3.11_test/chaco/examples/demo/canvas/canvas.py:21: DeprecationWarning: This module is meant for internal use only and it is not meant for use in library code. Importing from this module is deprecated and it will be removed in Enable 6.0. We highly recommend that you update your code and vendorize what is necessary.
  from enable.example_support import DemoFrame, demo_main
Traceback (most recent call last):
  File "/Users/cyliu/Documents/3.11_test/chaco/examples/demo/canvas/canvas.py", line 433, in <module>
    demo = demo_main(PlotFrame, size=(1000, 700), title="PlotCanvas")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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/.venvs/py311/lib/python3.11/site-packages/traits/has_traits.py", line 2164, in configure_traits
    rc = toolkit().view_application(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/toolkit.py", line 237, in view_application
    return view_application.view_application(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/view_application.py", line 92, in view_application
    return ViewApplication(
           ^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/view_application.py", line 127, in __init__
    self.ui = self.view.ui(
              ^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/view.py", line 457, in ui
    ui.ui(parent, kind)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/ui.py", line 234, in ui
    self.rebuild(self, parent)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/toolkit.py", line 168, in ui_live
    ui_live.ui_live(ui, parent)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_live.py", line 52, in ui_live
    _ui_dialog(ui, parent, BaseDialog.NONMODAL)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_live.py", line 72, in _ui_dialog
    BaseDialog.display_ui(ui, parent, style)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_base.py", line 294, in display_ui
    ui.owner.init(ui, parent, style)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_live.py", line 231, in init
    self.add_contents(panel(ui), bbox)
                      ^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_panel.py", line 270, in panel
    panel = _GroupPanel(content[0], ui).control
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_panel.py", line 621, in __init__
    layout = self._add_items(content, inner)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_panel.py", line 855, in _add_items
    editor = factory_method(
             ^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/editor_factory.py", line 117, in simple_editor
    return self.simple_editor_class(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/editor.py", line 540, in __init__
    self.old_value = getattr(self.object, self.name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/enable/enable/examples/_example_support.py", line 31, in _component_default
    return self._create_component()
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/chaco/examples/demo/canvas/canvas.py", line 427, in _create_component
    return self._create_window_simple()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/chaco/examples/demo/canvas/canvas.py", line 421, in _create_window_simple
    return Window(self, -1, component=viewport)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/enable/enable/qt/base_window.py", line 373, in __init__
    self.control = self._create_control(parent, self)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/enable/enable/qt/base_window.py", line 651, in _create_control
    return _QtWindow(parent, enable_window)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/enable/enable/qt/base_window.py", line 244, in __init__
    super().__init__(parent)
TypeError: 'PySide6.QtWidgets.QWidget.__init__' called with wrong argument types:
  PySide6.QtWidgets.QWidget.__init__(PlotFrame)
Supported signatures:
  PySide6.QtWidgets.QWidget.__init__(Optional[PySide6.QtWidgets.QWidget] = None, PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags))

Also, the '_create_viewport' in examples/demo/canvas/canvas.py is called by _create_window, thus changing the name will cause a no attribute error:

(py311) (base) cyliu@aus552cyliu chaco % python3.11 examples/demo/canvas/canvas.py 
/Users/cyliu/Documents/3.11_test/chaco/examples/demo/canvas/canvas.py:21: DeprecationWarning: This module is meant for internal use only and it is not meant for use in library code. Importing from this module is deprecated and it will be removed in Enable 6.0. We highly recommend that you update your code and vendorize what is necessary.
  from enable.example_support import DemoFrame, demo_main
Traceback (most recent call last):
  File "/Users/cyliu/Documents/3.11_test/chaco/examples/demo/canvas/canvas.py", line 433, in <module>
    demo = demo_main(PlotFrame, size=(1000, 700), title="PlotCanvas")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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/.venvs/py311/lib/python3.11/site-packages/traits/has_traits.py", line 2164, in configure_traits
    rc = toolkit().view_application(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/toolkit.py", line 237, in view_application
    return view_application.view_application(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/view_application.py", line 92, in view_application
    return ViewApplication(
           ^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/view_application.py", line 127, in __init__
    self.ui = self.view.ui(
              ^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/view.py", line 457, in ui
    ui.ui(parent, kind)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/ui.py", line 234, in ui
    self.rebuild(self, parent)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/toolkit.py", line 168, in ui_live
    ui_live.ui_live(ui, parent)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_live.py", line 52, in ui_live
    _ui_dialog(ui, parent, BaseDialog.NONMODAL)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_live.py", line 72, in _ui_dialog
    BaseDialog.display_ui(ui, parent, style)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_base.py", line 294, in display_ui
    ui.owner.init(ui, parent, style)
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_live.py", line 231, in init
    self.add_contents(panel(ui), bbox)
                      ^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_panel.py", line 270, in panel
    panel = _GroupPanel(content[0], ui).control
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_panel.py", line 621, in __init__
    layout = self._add_items(content, inner)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/qt/ui_panel.py", line 855, in _add_items
    editor = factory_method(
             ^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/editor_factory.py", line 117, in simple_editor
    return self.simple_editor_class(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/traitsui/traitsui/editor.py", line 540, in __init__
    self.old_value = getattr(self.object, self.name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/enable/enable/examples/_example_support.py", line 31, in _component_default
    return self._create_component()
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/chaco/examples/demo/canvas/canvas.py", line 427, in _create_component
    return self._create_window_simple()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cyliu/Documents/3.11_test/chaco/examples/demo/canvas/canvas.py", line 420, in _create_window_simple
    viewport = self._create_viewport()
               ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'PlotFrame' object has no attribute '_create_viewport'