You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
matplotlib.backends.qt_editor._formlayout.FormWidget.get() converts values of date and datetime fields into python datetime.date and datetime.datetime objects using toPyDate() and toPyDateTime() methods. These exist only in PyQt5; in PySide2 the corresponding functions are called toPython().
One way to fix this is to patch matplotlib.backends.qt_compat._setup_pyqt5() by adding the following lines under if QT_API == QT_API_PYSIDE2:
Traceback (most recent call last):
File "formwidget.py", line 8, in <module>
values = widget.get()
File "lib\site-packages\matplotlib\backends\qt_editor\_formlayout.py", line 346, in get
value = field.dateTime().toPyDateTime()
AttributeError: 'PySide2.QtCore.QDateTime' object has no attribute 'toPyDateTime'
Expected outcome
No output, especially no tracebacks.
Matplotlib version
Operating system: Windows 10
Matplotlib version: 3.3.0 (the bug seems to be in master too)
However note that _formlayout is explicitly private and not suitable for general consumption; we reserve the right to change the module without notice (for example, given that we don't actually use this feature internally, we could certainly decide to "fix" this by just deleting the whole feature). Consider using the PyPI package (https://pypi.org/project/formlayout/) instead.
OTOH this may be a good opportunity to fix the qt editor's behavior wrt units (currently it doesn't handle them at all...).
Thanks for the prompt answer. The issue actually boils down to the figure options editor: we are using date time values on the x axis extensively but the editor's axis limits shows date times as floats making adjustments difficult. I am monkey patching matplotlib.backends.qt_editor.figureoptions.figure_edit to convert the units to correct input widgets which made me discover the issue at hand. Fixing the editor to handle units correctly would indeed be more 'correct' approach.
Bug report
Bug summary
matplotlib.backends.qt_editor._formlayout.FormWidget.get()
converts values of date and datetime fields into pythondatetime.date
anddatetime.datetime
objects usingtoPyDate()
andtoPyDateTime()
methods. These exist only in PyQt5; in PySide2 the corresponding functions are calledtoPython()
.One way to fix this is to patch
matplotlib.backends.qt_compat._setup_pyqt5()
by adding the following lines underif QT_API == QT_API_PYSIDE2
:Code for reproduction
Actual outcome
Expected outcome
No output, especially no tracebacks.
Matplotlib version
master
too)print(matplotlib.get_backend())
): qt5aggThe text was updated successfully, but these errors were encountered: