Skip to content

Commit 3ead7f9

Browse files
committed
Fixed other QPrinter compat. issues
1 parent 617582e commit 3ead7f9

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

qwt/plot_renderer.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,11 @@ def renderDocument(
242242
if fmt in ("pdf", "ps"):
243243
printer = QPrinter()
244244
if fmt == "pdf":
245-
printer.setOutputFormat(QPrinter.PdfFormat)
245+
try:
246+
printer.setOutputFormat(QPrinter.PdfFormat)
247+
except AttributeError:
248+
# PyQt6 on Linux
249+
printer.setPrinterName("")
246250
else:
247251
printer.setOutputFormat(QPrinter.PostScriptFormat)
248252
printer.setColorMode(QPrinter.Color)

qwt/tests/test_bodedemo.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,19 +265,14 @@ def print_(self, unattended=False):
265265
dialog = QPrintDialog(printer)
266266
if unattended:
267267
# Configure QPrinter object to print to PDF file
268-
printer.setOutputFormat(QPrinter.PdfFormat)
268+
printer.setPrinterName("")
269269
printer.setOutputFileName(FNAME_PDF)
270270
dialog.accept()
271271
ok = True
272272
else:
273273
ok = dialog.exec_()
274274
if ok:
275275
renderer = QwtPlotRenderer()
276-
if QPrinter.GrayScale == printer.colorMode():
277-
renderer.setDiscardFlag(QwtPlotRenderer.DiscardBackground)
278-
renderer.setDiscardFlag(QwtPlotRenderer.DiscardCanvasBackground)
279-
renderer.setDiscardFlag(QwtPlotRenderer.DiscardCanvasFrame)
280-
renderer.setLayoutFlag(QwtPlotRenderer.FrameWithScales)
281276
renderer.renderTo(self.plot, printer)
282277

283278
def exportDocument(self):

0 commit comments

Comments
 (0)