Source code for betty.gui.text
"""
Provide text widgets for the Graphical User Interface.
"""
from typing import final
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QFont
from PyQt6.QtWidgets import QLabel
from typing_extensions import override
[docs]
class Text(QLabel):
"""
Display plain text.
"""
[docs]
def __init__(self, text: str | None = None):
super().__init__()
if text:
self.setText(text)
self.setTextFormat(Qt.TextFormat.RichText)
self.setWordWrap(True)
self.setTextInteractionFlags(
Qt.TextInteractionFlag.LinksAccessibleByKeyboard
| Qt.TextInteractionFlag.LinksAccessibleByMouse
| Qt.TextInteractionFlag.TextSelectableByKeyboard
| Qt.TextInteractionFlag.TextSelectableByMouse
)
self.setOpenExternalLinks(True)