Python 3.12.3 (main, Jun 18 2025, 17:59:45) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from qwt import tests
>>> tests.run()
Traceback (most recent call last):
File "/home/martin/.virtualenvs/venv/lib/python3.12/site-packages/qwt/tests/test_stylesheet.py", line 37, in <module>
test_stylesheet()
File "/home/martin/.virtualenvs/venv/lib/python3.12/site-packages/qwt/tests/test_stylesheet.py", line 33, in test_stylesheet
utils.test_widget(StyleSheetPlot, size=(600, 400))
File "/home/martin/.virtualenvs/venv/lib/python3.12/site-packages/qwt/tests/utils.py", line 301, in test_widget
central_widget.add_widget(widget)
File "/home/martin/.virtualenvs/venv/lib/python3.12/site-packages/qwt/tests/utils.py", line 252, in add_widget
self.layout().addWidget(widget)
File "/home/martin/.virtualenvs/venv/lib/python3.12/site-packages/qwt/plot_canvas.py", line 582, in event
self.updateStyleSheetInfo()
File "/home/martin/.virtualenvs/venv/lib/python3.12/site-packages/qwt/plot_canvas.py", line 809, in updateStyleSheetInfo
self.style().drawPrimitive(QStyle.PE_Widget, opt, painter, self)
File "/home/martin/.virtualenvs/venv/lib/python3.12/site-packages/qwt/null_paintdevice.py", line 59, in drawRects
device.drawRects(rects, rectCount)
File "/home/martin/.virtualenvs/venv/lib/python3.12/site-packages/qwt/plot_canvas.py", line 80, in drawRects
self.border.rectList += [rects.getRect().index(i)]
^^^^^^^^^^^^^
AttributeError: Error calling Python override of QFrame::event(): Error calling Python override of QPaintEngine::drawRects(): 'list' object has no attribute 'getRect'
^X^C^CTraceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/martin/.virtualenvs/venv/lib/python3.12/site-packages/qwt/tests/__init__.py", line 37, in run
app.exec()
The other testcases seem to work without trouble.
diff --git a/qwt/plot_canvas.py b/qwt/plot_canvas.py
index c7c7950..ff8705e 100644
--- a/qwt/plot_canvas.py
+++ b/qwt/plot_canvas.py
@@ -75,9 +75,16 @@ class QwtStyleSheetRecorder(QwtNullPaintDevice):
# Pyside
if isinstance(rects, (QRect, QRectF)):
self.border.list = [rects]
+ elif all(isinstance(rects, (QRect, QRectF)):
+ if isinstance(rects, list):
+ self.border.rectList += rects
+ else:
+ # That may not even be necessary
+ self.border.rectList += [r for r in rects]
else:
+ # Should we get here ?
for i in range(count):
- self.border.rectList += [rects.getRect().index(i)]
+ self.border.rectList += [rects[i]]
else:
# PyQt
for i in range(count):
``
Installing
PythonQwtversion 0.14.5 into a python 3.12.3 virtual environment together withPySide6(version 6.9.1) and running the stylesheet testcase results in the following backtrace:The other testcases seem to work without trouble.
It seems that the issue is caused by the handling of the
PySidebackend in theplotRectsimplementation insideplot_canvas.py. Something along the lines of this change seems to fix it (with some of the corner cases still present most likely not needed anymore):