From 23ecf6718051b9d20227e97b25e490f3ff741deb Mon Sep 17 00:00:00 2001 From: Richard Gerum Date: Thu, 25 Nov 2021 16:57:54 +0100 Subject: [PATCH] fixed dpi_ratio error for newer matplotlib versions --- pylustrator/QComplexWidgets.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pylustrator/QComplexWidgets.py b/pylustrator/QComplexWidgets.py index 142a13b..f5965db 100644 --- a/pylustrator/QComplexWidgets.py +++ b/pylustrator/QComplexWidgets.py @@ -1346,7 +1346,11 @@ def icon(self, name: str): """ get an icon with the given filename """ pm = QtGui.QPixmap(os.path.join(os.path.dirname(__file__), "icons", name)) if hasattr(pm, 'setDevicePixelRatio'): - pm.setDevicePixelRatio(self.canvas._dpi_ratio) + try: # older mpl < 3.5.0 + pm.setDevicePixelRatio(self.canvas._dpi_ratio) + except AttributeError: + pm.setDevicePixelRatio(self.canvas.device_pixel_ratio) + return QtGui.QIcon(pm) def setSelect(self):