PlotPyStack / PythonQwt

Qt plotting widgets for Python (pure Python reimplementation of Qwt C++ library)
https://pypi.org/project/PythonQwt/
Other
87 stars 25 forks source link

TypeError: QwtPlotDict.__init__() [...] with PySide 6.5.0 #74

Closed ZeeD closed 1 year ago

ZeeD commented 1 year ago

I'm using

(i.e. the current version of the packages)

and I'm facing errors. Even with the tests (from qwt import tests; tests.run()) I got a bunch of plots not working, and in the logs I have errors ending with AttributeError: 'BodePlot' object has no attribute '_QwtPlot__data'

PierreRaybaut commented 1 year ago

I can't reproduce any issue with latest versions of Python and PySide (Python 3.11.3, PySide 6.5.2 on Windows 11). Could you please tell me more about your configuration or even better copy/paste tracebacks here?

Thanks

ZeeD commented 1 year ago

Hi. thanks for the comment now I'm not at my workstation, and I'll try to send additional details as soon as possible. In the meantime could you have a look at the related pr? I remembered I've done some analysis when I found the issue

PierreRaybaut commented 1 year ago

Yes, I already have taken a look at PR #75 but I would prefer to begin by reproducing the issue.

ZeeD commented 1 year ago
$ python --version
Python 3.11.5
$ python -mvenv venv
$ . venv/bin/activate
(venv) $ pip install PySide6==6.5.0 PySide6-Addons==6.5.0 PySide6-Essentials==6.5.0 QtPy==2.3.1 PythonQwt==0.10.2

# ...

(venv) $ pip list
Package            Version
------------------ -------
numpy              1.25.2
packaging          23.1
pip                23.2
PySide6            6.5.0
PySide6-Addons     6.5.0
PySide6-Essentials 6.5.0
PythonQwt          0.10.2
QtPy               2.3.1
setuptools         68.1.2
shiboken6          6.5.0
(venv) $ python -c 'from qwt import tests; tests.run()'
qt.dbus.integration: Could not connect "org.freedesktop.IBus" to globalEngineChanged(QString)
qt.dbus.integration: Could not connect "org.freedesktop.IBus" to globalEngineChanged(QString)

# click on the "bode demo" item

Traceback (most recent call last):
  File "/tmp/venv/lib/python3.11/site-packages/qwt/tests/bodedemo.py", line 284, in <module>
    tests.test_widget(BodeDemo, (640, 480))
  File "/tmp/venv/lib/python3.11/site-packages/qwt/tests/__init__.py", line 242, in test_widget
    widget = widget_class()
             ^^^^^^^^^^^^^^
  File "/tmp/venv/lib/python3.11/site-packages/qwt/tests/bodedemo.py", line 201, in __init__
    self.plot = BodePlot(self)
                ^^^^^^^^^^^^^^
  File "/tmp/venv/lib/python3.11/site-packages/qwt/tests/bodedemo.py", line 92, in __init__
    QwtPlot.__init__(self, *args)
  File "/tmp/venv/lib/python3.11/site-packages/qwt/plot.py", line 304, in __init__
    QFrame.__init__(self, parent)
TypeError: QwtPlotDict.__init__() takes 1 positional argument but 2 were given
Exception ignored in: <function QwtPlot.__del__ at 0x7fbe12ec8860>
Traceback (most recent call last):
  File "/tmp/venv/lib/python3.11/site-packages/qwt/plot.py", line 365, in __del__
    self.setAutoReplot(False)
  File "/tmp/venv/lib/python3.11/site-packages/qwt/plot.py", line 1066, in setAutoReplot
    self.__data.autoReplot = tf
    ^^^^^^^^^^^
AttributeError: 'BodePlot' object has no attribute '_QwtPlot__data'
(venv) $ 
ZeeD commented 1 year ago

FWIW: this issue is not happening with PySide* version 6.5.2

PierreRaybaut commented 1 year ago

Ok, FYI, the AttributeError: 'BodePlot' object has no attribute '_QwtPlot__data' is just a symptom of the unexpected destruction of a QwtPlot object. I will have to handle this more explicitely/wisely to avoid users from being focused on this part of the traceback (see Issue #77).

Regarding the main issue here (TypeError: QwtPlotDict.__init__() takes 1 positional argument but 2 were given), I think that it may be a PySide bug relative to multiple inheritance management. This has always been a tricky problem to solve for Python-Qt bindings (PySide and PyQt) accross the major versions of Qt. ...so would it be acceptable to state that upgrading PySide to v6.5.2 is a good solution for this issue?

ZeeD commented 1 year ago

uhm... ok... I just fear that any (possible even minor) upgrade of PySide or any other related package may broke this part. but at least with current combination of PySide, QtPy, and PythonQwt I don't have issues.

PierreRaybaut commented 1 year ago

I'll do some tests before closing this issue, just to be sure that there is nothing to be done.

PierreRaybaut commented 1 year ago

I was able to reproduce the original issue with PySide 6.5.0 on Windows. This fix has been successfully tested on PySide 6.5.0, PySide 6.5.2 and PyQt5.