4 # |
4 # |
5 |
5 |
6 """ |
6 """ |
7 Module implementing a dialog to enter data for an image markup. |
7 Module implementing a dialog to enter data for an image markup. |
8 """ |
8 """ |
|
9 |
|
10 import contextlib |
9 |
11 |
10 from PyQt5.QtCore import pyqtSlot, QSize |
12 from PyQt5.QtCore import pyqtSlot, QSize |
11 from PyQt5.QtGui import QImage, QImageReader |
13 from PyQt5.QtGui import QImage, QImageReader |
12 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
14 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
13 |
15 |
77 } |
79 } |
78 |
80 |
79 inputFormats = [] |
81 inputFormats = [] |
80 readFormats = QImageReader.supportedImageFormats() |
82 readFormats = QImageReader.supportedImageFormats() |
81 for readFormat in readFormats: |
83 for readFormat in readFormats: |
82 try: |
84 with contextlib.suppress(KeyError): |
83 inputFormats.append(filters[bytes(readFormat).decode()]) |
85 inputFormats.append(filters[bytes(readFormat).decode()]) |
84 except KeyError: |
|
85 pass |
|
86 inputFormats.sort() |
86 inputFormats.sort() |
87 inputFormats.append(self.tr("All Files (*)")) |
87 inputFormats.append(self.tr("All Files (*)")) |
88 if filters["png"] in inputFormats: |
88 if filters["png"] in inputFormats: |
89 inputFormats.remove(filters["png"]) |
89 inputFormats.remove(filters["png"]) |
90 inputFormats.insert(0, filters["png"]) |
90 inputFormats.insert(0, filters["png"]) |