Source code for mantidimaging.gui.mvp_base.view
# Copyright (C) 2022 ISIS Rutherford Appleton Laboratory UKRI
# SPDX - License - Identifier: GPL-3.0-or-later
from logging import getLogger
from PyQt5.QtWidgets import QMainWindow, QMessageBox, QDialog
from mantidimaging.gui.utility import compile_ui
LOG = getLogger(__name__)
[docs]
class BaseMainWindowView(QMainWindow):
def __init__(self, parent, ui_file=None):
super().__init__(parent)
if ui_file is not None:
compile_ui(ui_file, self)
[docs]
def closeEvent(self, e):
LOG.debug('UI window closed')
self.cleanup()
super().closeEvent(e)
[docs]
def cleanup(self):
"""
Runs when the window is closed.
"""
pass
[docs]
def show_error_dialog(self, msg=""):
"""
Shows an error message.
:param msg: Error message string
"""
QMessageBox.critical(self, "Error", str(msg))
[docs]
def show_info_dialog(self, msg=""):
"""
Shows an information message.
:param msg: Information message string.
"""
QMessageBox.information(self, "Information", str(msg))
[docs]
class BaseDialogView(QDialog):
def __init__(self, parent, ui_file=None):
super().__init__(parent)
if ui_file is not None:
compile_ui(ui_file, self)
[docs]
def show_error_dialog(self, msg=""):
"""
Shows an error message.
:param msg: Error message string
"""
QMessageBox.critical(self, "Error", str(msg))