extracted function for preparation of text with html symbols

This commit is contained in:
iLLiCiTiT 2022-01-05 18:42:18 +01:00
parent 7d72481b86
commit 7107e797f0
2 changed files with 40 additions and 33 deletions

View file

@ -3,20 +3,23 @@ from Qt import QtWidgets, QtCore
from .widgets import ClickableFrame, ExpandBtn
def convert_text_for_html(text):
return (
text
.replace("<", "&#60;")
.replace(">", "&#62;")
.replace("\n", "<br>")
.replace(" ", "&nbsp;")
)
class TracebackWidget(QtWidgets.QWidget):
def __init__(self, tb_text, parent):
super(TracebackWidget, self).__init__(parent)
# Modify text to match html
# - add more replacements when needed
tb_text = (
tb_text
.replace("<", "&#60;")
.replace(">", "&#62;")
.replace("\n", "<br>")
.replace(" ", "&nbsp;")
)
tb_text = convert_text_for_html(tb_text)
expand_btn = ExpandBtn(self)
clickable_frame = ClickableFrame(self)
@ -103,6 +106,10 @@ class ErrorMessageBox(QtWidgets.QDialog):
self._report_data = report_data
self._content_widget = content_widget
@staticmethod
def convert_text_for_html(text):
return convert_text_for_html(text)
def _create_top_widget(self, parent_widget):
label_widget = QtWidgets.QLabel(parent_widget)
label_widget.setText(