bgcolor theme 설정
This commit is contained in:
westnife3 2025-08-28 14:30:37 +09:00
parent c90fdc4d25
commit 2f84848aca
4 changed files with 82 additions and 14 deletions

View File

@ -12,31 +12,62 @@ class Dashboard(QWidget):
super().__init__() super().__init__()
self.setWindowTitle("Server Monitor Dashboard") self.setWindowTitle("Server Monitor Dashboard")
self.setFixedSize(960, 640) self.setFixedSize(960, 640)
self.setStyleSheet("background-color: black;")
self.cards = {} self.cards = {}
theme = "normal" # "light", "normal", "dark"
colors = {
"cpu": {"light": "#ffcccc", "normal": "#cc6666", "dark": "#662222"},
"ram": {"light": "#cceeff", "normal": "#66aacc", "dark": "#224455"},
"disk": {"light": "#e6e6e6", "normal": "#999999", "dark": "#2e2e2e"},
"uptime": {"light": "#e0ccff", "normal": "#a080e0", "dark": "#3a2a5a"},
"cpu_temp": {"light": "#ffd9cc", "normal": "#ff9966", "dark": "#66331f"},
"gpu_temp": {"light": "#ffe6cc", "normal": "#ffb366", "dark": "#66441f"},
"gpu_usage": {"light": "#cce6ff", "normal": "#66aadd", "dark": "#1f3a4f"},
"swap": {"light": "#ccffe6", "normal": "#66ccaa", "dark": "#1f4f3a"},
"download": {"light": "#ccd9ff", "normal": "#6688cc", "dark": "#1f2a4f"},
"upload": {"light": "#e0ccff", "normal": "#a080e0", "dark": "#3a2a5a"},
"alive": {"light": "#ccffcc", "normal": "#66cc66", "dark": "#1f4f1f"},
"processes": {"light": "#f0ccff", "normal": "#cc66cc", "dark": "#4f1f4f"},
}
self.titles = [
{"id": key, "title": title, "bg_color": colors[key][theme]}
for key, title in [
("cpu", "CPU🔲"), ("ram", "RAM🎟"), ("disk", "DISK🖥"), ("uptime", "UP🕒"),
("cpu_temp", "CPU🌡"), ("gpu_temp", "GPU🌡"), ("gpu_usage", "GPU📊"),
("swap", "SWAP♻"), ("download", "DN📥"), ("upload", "UP📤"),
("alive", "Alive🔥"), ("processes", "PS📈"),
]
]
"""
self.titles = [ self.titles = [
{"id": "cpu", "title": "CPU🔲", "bg_color": "#2e2324"}, {"id": "cpu", "title": "CPU🔲", "bg_color": "#2e2324"},
{"id": "ram", "title": "RAM🎟", "bg_color": "#2e3e43"}, {"id": "ram", "title": "RAM🎟", "bg_color": "#2e3e43"},
{"id": "disk", "title": "DISK🖥", "bg_color": "#2e2e2e"}, {"id": "disk", "title": "DISK🖥", "bg_color": "#2e2e2e"},
{"id": "uptime", "title": "UP🕒", "bg_color": "#2e2e2e"}, {"id": "uptime", "title": "UP🕒", "bg_color": "#2e2a36"},
{"id": "cpu_temp", "title": "CPU🌡", "bg_color": "#2e2e2e"}, {"id": "cpu_temp", "title": "CPU🌡", "bg_color": "#3a1f1f"},
{"id": "gpu_temp", "title": "GPU🌡", "bg_color": "#2e2e2e"}, {"id": "gpu_temp", "title": "GPU🌡", "bg_color": "#3a2f1f"},
{"id": "gpu_usage", "title": "GPU📊", "bg_color": "#2e2e2e"}, {"id": "gpu_usage", "title": "GPU📊", "bg_color": "#1f2f3a"},
{"id": "swap", "title": "SWAP♻", "bg_color": "#2e2e2e"}, {"id": "swap", "title": "SWAP♻", "bg_color": "#1f3a2f"},
{"id": "download", "title": "DN📥", "bg_color": "#2e2e2e"}, {"id": "download", "title": "DN📥", "bg_color": "#1f1f3a"},
{"id": "upload", "title": "UP📤", "bg_color": "#2e2e2e"}, {"id": "upload", "title": "UP📤", "bg_color": "#1f1f2a"},
{"id": "alive", "title": "Alive🔥", "bg_color": "#2e2e2e"}, {"id": "alive", "title": "Alive🔥", "bg_color": "#1f3a1f"},
{"id": "processes", "title": "PS📈", "bg_color": "#2e2e2e"}, {"id": "processes", "title": "PS📈", "bg_color": "#2a1f3a"},
] ]
"""
# 메인 레이아웃 # 메인 레이아웃
self.layout = QVBoxLayout(self) self.layout = QVBoxLayout(self)
self.layout.setSpacing(0)
self.layout.setContentsMargins(0, 0, 0, 0)
self.setLayout(self.layout) self.setLayout(self.layout)
# 카드 그리드 # 카드 그리드
self.grid = QGridLayout() self.grid = QGridLayout()
self.grid.setContentsMargins(0, 0, 0, 0) # (left, top, right, bottom)
self.grid.setSpacing(5) self.grid.setSpacing(5)
self.grid.setContentsMargins(0, 0, 0, 0) # (left, top, right, bottom)
self.layout.addLayout(self.grid) self.layout.addLayout(self.grid)
# 카드 생성 # 카드 생성
for i, item in enumerate(self.titles): for i, item in enumerate(self.titles):

31
qtDash/monitor.py Normal file
View File

@ -0,0 +1,31 @@
from PyQt6.QtWidgets import QApplication, QMainWindow
from PyQt6.QtGui import QGuiApplication
import sys
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Dashboard")
if __name__ == "__main__":
app = QApplication(sys.argv)
# 사용 가능한 모니터 목록 가져오기
screens = QGuiApplication.screens()
print("사용 가능한 모니터 수:", len(screens))
# 예: 두 번째 모니터 선택 (인덱스 1)
target_screen_index = 1 if len(screens) > 1 else 0
target_screen = screens[target_screen_index]
# 메인 윈도우 생성
window = MainWindow()
# 선택한 모니터의 geometry로 이동
geometry = target_screen.geometry()
window.setGeometry(geometry)
# 전체화면으로 표시
window.showFullScreen()
sys.exit(app.exec())

View File

@ -8,17 +8,20 @@ class MonitorCard(QWidget):
super().__init__() super().__init__()
self.setStyleSheet(f""" self.setStyleSheet(f"""
background-color: {bg_color}; background-color: {bg_color};
border-radius: 10px;
border: 1px solid #444; border: 1px solid #444;
border-radius: 4px;
""") """)
layout = QVBoxLayout() layout = QVBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(0)
self.title = QLabel(title) self.title = QLabel(title)
self.title.setStyleSheet("font-weight: bold; font-size: 50px; color: white;") self.title.setStyleSheet("font-weight: bold; font-size: 30px; color: white;")
self.title.setAlignment(Qt.AlignmentFlag.AlignCenter) self.title.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.value = QLabel("--") self.value = QLabel("--")
self.value.setStyleSheet("font-size: 40px; font-weight: bold; color: white;") self.value.setStyleSheet("font-size: 45px; font-weight: bold; color: white;")
self.value.setAlignment(Qt.AlignmentFlag.AlignCenter) self.value.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.spinner = QLabel() self.spinner = QLabel()

3
start_dashboard.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
source /home/mkpark/GiteaProjects/pyqt6Dashboard/.venv/bin/activate
python /home/mkpark/GiteaProjects/pyqt6Dashboard/qtDash/main.py