Skip to content
Snippets Groups Projects

Error management

Merged SIMAILA DJALIM requested to merge error_management into main
2 files
+ 41
6
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 32
0
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
Loading