# -*- coding: utf-8 -*-
from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtWidgets import QDialog,QDialogButtonBox,QGridLayout,QSizePolicy
from qgis.gui import QgsMessageBar
from qgis.core import Qgis

class TextError(QtWidgets.QDialog):
    def __init__(self,title, text, parent=None):
        super(TextError, self).__init__(parent)
        self.resize(400, 300)
        self.gridLayout = QtWidgets.QGridLayout(self)
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.textBrowser = QtWidgets.QTextBrowser(self)
        self.verticalLayout.addWidget(self.textBrowser)
        self.buttonBox = QtWidgets.QDialogButtonBox(self)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Ok)
        self.verticalLayout.addWidget(self.buttonBox)
        self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)

        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)

        if type(text) in (list, tuple):
            text = "\n".join(text)
        self.textBrowser.setText(text)
        self.setWindowTitle(title)