eric6/WebBrowser/Tools/PrintToPdfDialog.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
40 self.pdfFilePicker.setFilters(self.tr( 40 self.pdfFilePicker.setFilters(self.tr(
41 "PDF Files (*.pdf);;" 41 "PDF Files (*.pdf);;"
42 "All Files (*)")) 42 "All Files (*)"))
43 if not os.path.isabs(filePath): 43 if not os.path.isabs(filePath):
44 documentsPath = QStandardPaths.writableLocation( 44 documentsPath = QStandardPaths.writableLocation(
45 QStandardPaths.DocumentsLocation) 45 QStandardPaths.StandardLocation.DocumentsLocation)
46 if documentsPath: 46 if documentsPath:
47 filePath = os.path.join(documentsPath, filePath) 47 filePath = os.path.join(documentsPath, filePath)
48 else: 48 else:
49 filePath = os.path.abspath(filePath) 49 filePath = os.path.abspath(filePath)
50 self.pdfFilePicker.setText(filePath, toNative=True) 50 self.pdfFilePicker.setText(filePath, toNative=True)
51 51
52 self.__currentPageLayout = QPageLayout( 52 self.__currentPageLayout = QPageLayout(
53 QPageSize(QPageSize.A4), QPageLayout.Portrait, 53 QPageSize(QPageSize.PageSizeId.A4),
54 QPageLayout.Orientation.Portrait,
54 QMarginsF(0.0, 0.0, 0.0, 0.0)) 55 QMarginsF(0.0, 0.0, 0.0, 0.0))
55 56
56 self.__updatePageLayoutLabel() 57 self.__updatePageLayoutLabel()
57 58
58 @pyqtSlot() 59 @pyqtSlot()
62 """ 63 """
63 printer = QPrinter() 64 printer = QPrinter()
64 printer.setPageLayout(self.__currentPageLayout) 65 printer.setPageLayout(self.__currentPageLayout)
65 66
66 dlg = QPageSetupDialog(printer, self) 67 dlg = QPageSetupDialog(printer, self)
67 if dlg.exec() == QDialog.Accepted: 68 if dlg.exec() == QDialog.DialogCode.Accepted:
68 self.__currentPageLayout = printer.pageLayout() 69 self.__currentPageLayout = printer.pageLayout()
69 self.__updatePageLayoutLabel() 70 self.__updatePageLayoutLabel()
70 71
71 def __updatePageLayoutLabel(self): 72 def __updatePageLayoutLabel(self):
72 """ 73 """
73 Private method to update the page layout label. 74 Private method to update the page layout label.
74 """ 75 """
75 if self.__currentPageLayout.orientation() == QPageLayout.Portrait: 76 if (
77 self.__currentPageLayout.orientation() ==
78 QPageLayout.Orientation.Portrait
79 ):
76 orientation = self.tr("Portrait") 80 orientation = self.tr("Portrait")
77 else: 81 else:
78 orientation = self.tr("Landscape") 82 orientation = self.tr("Landscape")
79 self.pageLayoutLabel.setText( 83 self.pageLayoutLabel.setText(
80 self.tr("{0}, {1}", "page size, page orientation").format( 84 self.tr("{0}, {1}", "page size, page orientation").format(

eric ide

mercurial