Skip to content

Commit a310f3e

Browse files
committed
Fixed QPrinter obsolete members issues
1 parent 6198adc commit a310f3e

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

plotpy/plot/interactive.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,20 @@ def save(self, fname, format, draft):
200200
"""
201201
if isinstance(fname, str):
202202
if format == "pdf":
203-
if draft:
204-
mode = QW.QPrinter.ScreenResolution
205-
else:
203+
try:
206204
mode = QPrinter.HighResolution
205+
except AttributeError:
206+
# Some PySide6 / PyQt6 versions do not have this attribute on Linux
207+
mode = QPrinter.ScreenResolution
208+
if draft:
209+
mode = QPrinter.ScreenResolution
207210
printer = QPrinter(mode)
208-
printer.setOutputFormat(QPrinter.PdfFormat)
209-
printer.setOrientation(QPrinter.Landscape)
211+
try:
212+
printer.setOutputFormat(QPrinter.PdfFormat)
213+
except AttributeError:
214+
# PyQt6 on Linux
215+
printer.setPrinterName("")
216+
printer.setPageOrientation(QG.QPageLayout.Landscape)
210217
printer.setOutputFileName(fname)
211218
printer.setCreator("plotpy.pyplot")
212219
self.print_(printer)

0 commit comments

Comments
 (0)