|
28 | 28 | # IMPORT (External Dependencies)
|
29 | 29 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
30 | 30 |
|
31 |
| -from PyQt5.Qt import QWidget |
32 |
| -from PyQt5.QtWidgets import QMessageBox |
| 31 | +from qgis.PyQt.QtWidgets import QMessageBox, QWidget |
33 | 32 |
|
34 | 33 |
|
35 | 34 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
44 | 43 | # ROUTINES
|
45 | 44 | # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
46 | 45 |
|
47 |
| -def msg_critical(exception, widget = None): |
48 | 46 |
|
49 |
| - _msg('critical', translate('global', 'Critical error'), exception, widget) |
| 47 | +def msg_critical(exception, widget=None): |
50 | 48 |
|
51 |
| -def msg_warning(exception, widget = None): |
| 49 | + _msg("critical", translate("global", "Critical error"), exception, widget) |
52 | 50 |
|
53 |
| - _msg('warning', translate('global', 'Warning'), exception, widget) |
54 | 51 |
|
55 |
| -def _msg(msg_type, msg_title, exception, widget = None): |
| 52 | +def msg_warning(exception, widget=None): |
| 53 | + |
| 54 | + _msg("warning", translate("global", "Warning"), exception, widget) |
| 55 | + |
| 56 | + |
| 57 | +def _msg(msg_type, msg_title, exception, widget=None): |
56 | 58 |
|
57 | 59 | if not isinstance(exception, Exception):
|
58 |
| - raise QgistTypeError(translate('global', '"exception" must be of type Exception. (msg)')) |
| 60 | + raise QgistTypeError( |
| 61 | + translate("global", '"exception" must be of type Exception. (msg)') |
| 62 | + ) |
59 | 63 | if not isinstance(widget, QWidget) and widget is not None:
|
60 |
| - raise QgistTypeError(translate('global', '"widget" must be of type QWidget or None. (msg)')) |
| 64 | + raise QgistTypeError( |
| 65 | + translate("global", '"widget" must be of type QWidget or None. (msg)') |
| 66 | + ) |
61 | 67 |
|
62 | 68 | if len(exception.args) == 0:
|
63 |
| - msg = translate('global', 'Internal error. No description can be provided. Please file a bug. (msg)') |
| 69 | + msg = translate( |
| 70 | + "global", |
| 71 | + "Internal error. No description can be provided. Please file a bug. (msg)", |
| 72 | + ) |
64 | 73 | else:
|
65 | 74 | msg = str(exception.args[0])
|
66 | 75 |
|
67 | 76 | getattr(QMessageBox, msg_type)(
|
68 |
| - widget, |
69 |
| - msg_title, |
70 |
| - msg, |
71 |
| - QMessageBox.Ok |
72 |
| - ) |
| 77 | + widget, msg_title, msg, QMessageBox.StandardButton.Ok |
| 78 | + ) |
0 commit comments