-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreferences_window.py
More file actions
36 lines (27 loc) · 1.26 KB
/
Copy pathpreferences_window.py
File metadata and controls
36 lines (27 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from typing import Dict, Optional
from PySide6.QtWidgets import QDialog, QVBoxLayout, QLabel, QPushButton, QColorDialog
class PreferencesWindow(QDialog):
def __init__(self, parent: Optional[QDialog] = None) -> None:
super().__init__(parent)
self.setWindowTitle("Preferences")
self.layout = QVBoxLayout()
self.errorColors: Dict[str, QPushButton] = {}
for error_type, color in error_type_color_map.items():
label = QLabel(f"{error_type}:")
self.layout.addWidget(label)
colorButton = QPushButton()
colorButton.setStyleSheet(f"background-color: {color.name()}")
colorButton.clicked.connect(
lambda _, error_type=error_type: self.setColor(error_type)
)
self.layout.addWidget(colorButton)
self.errorColors[error_type] = colorButton
self.setLayout(self.layout)
self.setMinimumWidth(300) # Set minimum width for the dialog
def setColor(self, error_type: str) -> None:
color = QColorDialog.getColor()
if color.isValid():
self.errorColors[error_type].setStyleSheet(
f"background-color: {color.name()}"
)
error_type_color_map[error_type] = color