eric7/Snapshot/SnapWidget.py

branch
eric7
changeset 9162
8b75b1668583
parent 9152
8a68afaf1ba2
equal deleted inserted replaced
9161:90939b08da20 9162:8b75b1668583
15 import pathlib 15 import pathlib
16 import re 16 import re
17 import contextlib 17 import contextlib
18 18
19 from PyQt6.QtCore import ( 19 from PyQt6.QtCore import (
20 pyqtSlot, Qt, QFile, QTimer, QPoint, QMimeData, QLocale, QStandardPaths, 20 pyqtSlot, Qt, QTimer, QPoint, QMimeData, QLocale, QStandardPaths
21 QIODevice
22 ) 21 )
23 from PyQt6.QtGui import QImageWriter, QPixmap, QDrag, QKeySequence, QShortcut 22 from PyQt6.QtGui import QImageWriter, QPixmap, QDrag, QKeySequence, QShortcut
24 from PyQt6.QtWidgets import QWidget, QApplication 23 from PyQt6.QtWidgets import QWidget, QApplication
25 24
26 from EricWidgets import EricFileDialog, EricMessageBox 25 from EricWidgets import EricFileDialog, EricMessageBox
238 " Overwrite it?</p>").format(fileName), 237 " Overwrite it?</p>").format(fileName),
239 icon=EricMessageBox.Warning) 238 icon=EricMessageBox.Warning)
240 if not res: 239 if not res:
241 return False 240 return False
242 241
243 file = QFile(fileName) 242 ok = self.__snapshot.save(fileName)
244 if not file.open(QIODevice.OpenModeFlag.WriteOnly):
245 EricMessageBox.warning(
246 self, self.tr("Save Snapshot"),
247 self.tr("Cannot write file '{0}:\n{1}.")
248 .format(fileName, file.errorString()))
249 return False
250
251 ok = self.__snapshot.save(file)
252 file.close()
253
254 if not ok: 243 if not ok:
255 EricMessageBox.warning( 244 EricMessageBox.warning(
256 self, self.tr("Save Snapshot"), 245 self, self.tr("Save Snapshot"),
257 self.tr("Cannot write file '{0}:\n{1}.") 246 self.tr("Cannot write file '{0}'.").format(fileName))
258 .format(fileName, file.errorString()))
259 247
260 return ok 248 return ok
261 249
262 def __autoIncFilename(self): 250 def __autoIncFilename(self):
263 """ 251 """

eric ide

mercurial