first ui widget placement
This commit is contained in:
35
ui/widgets/placeholder_widget.py
Normal file
35
ui/widgets/placeholder_widget.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from PySide6.QtWidgets import QWidget, QLabel, QVBoxLayout
|
||||
from PySide6.QtGui import QPalette, QColor
|
||||
from PySide6.QtCore import Qt
|
||||
|
||||
class PlaceholderWidget(QWidget):
|
||||
"""A custom widget to display a colored background with centered text."""
|
||||
def __init__(self, text: str, color: str, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setAutoFillBackground(True)
|
||||
self.set_color(color)
|
||||
|
||||
self.label = QLabel(text)
|
||||
self.label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
font = self.label.font()
|
||||
font.setPointSize(24)
|
||||
self.label.setFont(font)
|
||||
self.label.setWordWrap(True)
|
||||
|
||||
layout = QVBoxLayout(self)
|
||||
layout.addWidget(self.label)
|
||||
self.setLayout(layout)
|
||||
|
||||
def set_text(self, text: str):
|
||||
self.label.setText(text)
|
||||
|
||||
def set_color(self, color: str):
|
||||
palette = self.palette()
|
||||
palette.setColor(QPalette.ColorRole.Window, QColor(color))
|
||||
self.setPalette(palette)
|
||||
|
||||
def set_text_color(self, color: str):
|
||||
palette = self.label.palette()
|
||||
palette.setColor(QPalette.ColorRole.WindowText, QColor(color))
|
||||
self.label.setPalette(palette)
|
||||
Reference in New Issue
Block a user