WebBrowser/Tools/PrintToPdfDialog.py

changeset 5181
1948b27d7b21
parent 5038
df7103c3f2a6
child 5389
9b1c800daff3
--- a/WebBrowser/Tools/PrintToPdfDialog.py	Sat Sep 24 18:00:30 2016 +0200
+++ b/WebBrowser/Tools/PrintToPdfDialog.py	Tue Sep 27 19:41:11 2016 +0200
@@ -9,7 +9,9 @@
 
 from __future__ import unicode_literals
 
-from PyQt5.QtCore import pyqtSlot, QMarginsF
+import os
+
+from PyQt5.QtCore import pyqtSlot, QMarginsF, QStandardPaths
 from PyQt5.QtGui import QPageLayout, QPageSize
 from PyQt5.QtPrintSupport import QPrinter, QPageSetupDialog
 from PyQt5.QtWidgets import QDialog
@@ -40,6 +42,13 @@
         self.pdfFilePicker.setFilters(self.tr(
             "PDF Files (*.pdf);;"
             "All Files (*)"))
+        if not os.path.isabs(filePath):
+            documentsPath = QStandardPaths.writableLocation(
+                QStandardPaths.DocumentsLocation)
+            if documentsPath:
+                filePath = os.path.join(documentsPath, filePath)
+            else:
+                filePath = os.path.abspath(filePath)
         self.pdfFilePicker.setText(filePath, toNative=True)
         
         self.__currentPageLayout = QPageLayout(

eric ide

mercurial