Wobuzz/wobuzz/ui/settings/sub_category.py

32 lines
960 B
Python
Raw Normal View History

2025-03-01 20:03:33 +01:00
#!/usr/bin/python3
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QFont
from PyQt6.QtWidgets import QLabel, QSizePolicy, QFormLayout
2025-03-01 20:03:33 +01:00
from ..custom_widgets import GroupBox
2025-03-01 20:03:33 +01:00
class SubCategory(GroupBox):
2025-03-01 20:03:33 +01:00
description_font = QFont()
description_font.setPointSize(8)
def __init__(self, title: str, description: str=None, parent=None):
2025-03-01 20:03:33 +01:00
super().__init__(title, parent)
self.layout = QFormLayout()
self.setLayout(self.layout)
if description is not None:
self.description = QLabel(description + "\n", self)
self.layout.addRow(self.description)
2025-03-01 20:03:33 +01:00
def add_setting(self, text: str, setting, description: str=None):
self.layout.addRow(text, setting)
if description is not None:
description_label = QLabel(" " + description.replace("\n", "\n "))
2025-03-01 20:03:33 +01:00
description_label.setFont(self.description_font)
self.layout.addRow(description_label)