From 2f84848aca6a65f447e990dadde7757381aa41f0 Mon Sep 17 00:00:00 2001 From: westnife3 <31227227+westnife3@users.noreply.github.com> Date: Thu, 28 Aug 2025 14:30:37 +0900 Subject: [PATCH] =?UTF-8?q?refs=20#=20bgcolor=20theme=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qtDash/main.py | 53 +++++++++++++++++++++++++++++++++--------- qtDash/monitor.py | 31 ++++++++++++++++++++++++ qtDash/monitor_card.py | 9 ++++--- start_dashboard.sh | 3 +++ 4 files changed, 82 insertions(+), 14 deletions(-) create mode 100644 qtDash/monitor.py create mode 100755 start_dashboard.sh diff --git a/qtDash/main.py b/qtDash/main.py index 2764a26..c5cb58f 100644 --- a/qtDash/main.py +++ b/qtDash/main.py @@ -12,31 +12,62 @@ class Dashboard(QWidget): super().__init__() self.setWindowTitle("Server Monitor Dashboard") self.setFixedSize(960, 640) - + self.setStyleSheet("background-color: black;") 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 = [ {"id": "cpu", "title": "CPU🔲", "bg_color": "#2e2324"}, {"id": "ram", "title": "RAM🎟", "bg_color": "#2e3e43"}, {"id": "disk", "title": "DISK🖥", "bg_color": "#2e2e2e"}, - {"id": "uptime", "title": "UP🕒", "bg_color": "#2e2e2e"}, - {"id": "cpu_temp", "title": "CPU🌡️", "bg_color": "#2e2e2e"}, - {"id": "gpu_temp", "title": "GPU🌡️", "bg_color": "#2e2e2e"}, - {"id": "gpu_usage", "title": "GPU📊", "bg_color": "#2e2e2e"}, - {"id": "swap", "title": "SWAP♻️", "bg_color": "#2e2e2e"}, - {"id": "download", "title": "DN📥", "bg_color": "#2e2e2e"}, - {"id": "upload", "title": "UP📤", "bg_color": "#2e2e2e"}, - {"id": "alive", "title": "Alive🔥", "bg_color": "#2e2e2e"}, - {"id": "processes", "title": "PS📈", "bg_color": "#2e2e2e"}, + {"id": "uptime", "title": "UP🕒", "bg_color": "#2e2a36"}, + {"id": "cpu_temp", "title": "CPU🌡️", "bg_color": "#3a1f1f"}, + {"id": "gpu_temp", "title": "GPU🌡️", "bg_color": "#3a2f1f"}, + {"id": "gpu_usage", "title": "GPU📊", "bg_color": "#1f2f3a"}, + {"id": "swap", "title": "SWAP♻️", "bg_color": "#1f3a2f"}, + {"id": "download", "title": "DN📥", "bg_color": "#1f1f3a"}, + {"id": "upload", "title": "UP📤", "bg_color": "#1f1f2a"}, + {"id": "alive", "title": "Alive🔥", "bg_color": "#1f3a1f"}, + {"id": "processes", "title": "PS📈", "bg_color": "#2a1f3a"}, ] + """ # 메인 레이아웃 self.layout = QVBoxLayout(self) + self.layout.setSpacing(0) + self.layout.setContentsMargins(0, 0, 0, 0) self.setLayout(self.layout) # 카드 그리드 self.grid = QGridLayout() - self.grid.setContentsMargins(0, 0, 0, 0) # (left, top, right, bottom) self.grid.setSpacing(5) + self.grid.setContentsMargins(0, 0, 0, 0) # (left, top, right, bottom) self.layout.addLayout(self.grid) # 카드 생성 for i, item in enumerate(self.titles): diff --git a/qtDash/monitor.py b/qtDash/monitor.py new file mode 100644 index 0000000..5731b5d --- /dev/null +++ b/qtDash/monitor.py @@ -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()) diff --git a/qtDash/monitor_card.py b/qtDash/monitor_card.py index aabaf86..35970e4 100644 --- a/qtDash/monitor_card.py +++ b/qtDash/monitor_card.py @@ -8,17 +8,20 @@ class MonitorCard(QWidget): super().__init__() self.setStyleSheet(f""" background-color: {bg_color}; - border-radius: 10px; border: 1px solid #444; + border-radius: 4px; """) layout = QVBoxLayout() + layout.setContentsMargins(0, 0, 0, 0) + layout.setSpacing(0) + 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.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.spinner = QLabel() diff --git a/start_dashboard.sh b/start_dashboard.sh new file mode 100755 index 0000000..1f72ea4 --- /dev/null +++ b/start_dashboard.sh @@ -0,0 +1,3 @@ +#!/bin/bash +source /home/mkpark/GiteaProjects/pyqt6Dashboard/.venv/bin/activate +python /home/mkpark/GiteaProjects/pyqt6Dashboard/qtDash/main.py