eric7/WebBrowser/PageScreenDialog.py

branch
eric7
changeset 9162
8b75b1668583
parent 9153
506e35e424d5
equal deleted inserted replaced
9161:90939b08da20 9162:8b75b1668583
7 Module implementing a dialog to save a screenshot of a web page. 7 Module implementing a dialog to save a screenshot of a web page.
8 """ 8 """
9 9
10 import pathlib 10 import pathlib
11 11
12 from PyQt6.QtCore import pyqtSlot, Qt, QFile, QSize, QIODevice 12 from PyQt6.QtCore import pyqtSlot, Qt, QSize
13 from PyQt6.QtGui import QImage, QPainter, QPixmap 13 from PyQt6.QtGui import QImage, QPainter, QPixmap
14 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton 14 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton
15 15
16 from EricWidgets import EricFileDialog, EricMessageBox 16 from EricWidgets import EricFileDialog, EricMessageBox
17 17
85 " Overwrite it?</p>").format(fileName), 85 " Overwrite it?</p>").format(fileName),
86 icon=EricMessageBox.Warning) 86 icon=EricMessageBox.Warning)
87 if not res: 87 if not res:
88 return False 88 return False
89 89
90 file = QFile(fileName) 90 res = self.__pagePixmap.save(fileName)
91 if not file.open(QIODevice.OpenModeFlag.WriteOnly):
92 EricMessageBox.warning(
93 self,
94 self.tr("Save Page Screen"),
95 self.tr("Cannot write file '{0}:\n{1}.")
96 .format(fileName, file.errorString()))
97 return False
98
99 res = self.__pagePixmap.save(file)
100 file.close()
101
102 if not res: 91 if not res:
103 EricMessageBox.warning( 92 EricMessageBox.warning(
104 self, 93 self,
105 self.tr("Save Page Screen"), 94 self.tr("Save Page Screen"),
106 self.tr("Cannot write file '{0}:\n{1}.") 95 self.tr("Cannot write file '{0}'.").format(fileName))
107 .format(fileName, file.errorString()))
108 return False 96 return False
109 97
110 return True 98 return True
111 99
112 @pyqtSlot(QAbstractButton) 100 @pyqtSlot(QAbstractButton)

eric ide

mercurial