start repository
This commit is contained in:
26
TextFormat.py
Normal file
26
TextFormat.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from dataclasses import dataclass, field
|
||||
from PySide6 import QtWidgets, QtGui, QtCore
|
||||
|
||||
@dataclass
|
||||
class TextFormat:
|
||||
font_family: str = "Segoe UI"
|
||||
font_size: str = "10"
|
||||
bold: bool = False
|
||||
italic: bool = False
|
||||
underline: bool = False
|
||||
fg_color: tuple[int] = field(default=(0,0,0))
|
||||
format: QtGui.QTextCharFormat = field(default_factory=QtGui.QTextCharFormat, init=False, repr=False)
|
||||
|
||||
def __post_init__(self):
|
||||
format = QtGui.QTextCharFormat()
|
||||
format.setFontFamily(self.font_family)
|
||||
format.setFontPointSize(int(self.font_size))
|
||||
format.setForeground(QtGui.QColor(*self.fg_color))
|
||||
if self.bold:
|
||||
format.setFontWeight(QtGui.QFont.Bold)
|
||||
if self.italic:
|
||||
format.setFontItalic(True)
|
||||
if self.underline:
|
||||
format.setUnderlineStyle(QtGui.QTextCharFormat.SingleUnderline)
|
||||
|
||||
self.format = format
|
||||
Reference in New Issue
Block a user