Skip to content
Snippets Groups Projects
Commit 7bb86e26 authored by Djalim Simaila's avatar Djalim Simaila
Browse files

Added ErrorPopup window

parent 5897f874
No related branches found
No related tags found
1 merge request!16Error management
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QMessageBox
class ErrorPopup(object):
def __init__(self,error_text,details = None,button_label = None,button_callback=None):
self.error_text = error_text
self.button_label = button_label
self.button_callback = button_callback
self.details = details
def show_popup(self):
msg = QMessageBox()
msg.setWindowTitle("Erreur")
msg.setText("Erreur: " + self.error_text)
msg.setIcon(QMessageBox.Critical)
if self.button_label is not None and self.button_callback is not None:
msg.setStandardButtons(QMessageBox.Cancel|QMessageBox.Retry)
msg.setDefaultButton(QMessageBox.Cancel)
msg.button(QMessageBox.Cancel).clicked.connect(msg.close)
msg.button(QMessageBox.Retry).setText(self.button_label)
msg.button(QMessageBox.Retry).clicked.connect(self.button_callback)
else:
msg.setStandardButtons(QMessageBox.Ok)
msg.setDefaultButton(QMessageBox.Ok)
msg.button(QMessageBox.Ok).clicked.connect(msg.close)
msg.setInformativeText(self.error_text)
if self.details is not None:
msg.setDetailedText(self.details)
msg.exec_()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment