From c90fdc4d2504b0f5228b385d8ff8c4d86a9602bc Mon Sep 17 00:00:00 2001 From: westnife3 Date: Thu, 28 Aug 2025 13:43:43 +0900 Subject: [PATCH] refs # qtdash monitor select --- .gitignore | 2 +- qtDash/main.py | 49 ++++++++++++++++++++++++++++++++---------- qtDash/monitor_card.py | 6 +++--- qtDash/monitor_data.py | 25 +++++++++++---------- qtDash/t.py | 32 --------------------------- 5 files changed, 54 insertions(+), 60 deletions(-) delete mode 100644 qtDash/t.py diff --git a/.gitignore b/.gitignore index 5d381cc..f295d3d 100644 --- a/.gitignore +++ b/.gitignore @@ -158,5 +158,5 @@ cython_debug/ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ +.idea/ diff --git a/qtDash/main.py b/qtDash/main.py index a2eb313..2764a26 100644 --- a/qtDash/main.py +++ b/qtDash/main.py @@ -1,6 +1,7 @@ # main.py from PyQt6.QtWidgets import QApplication, QWidget, QGridLayout, QVBoxLayout from PyQt6.QtCore import QTimer +from PyQt6.QtGui import QGuiApplication import sys from loading_overlay import LoadingOverlay from monitor_data import get_monitor_data @@ -14,9 +15,18 @@ class Dashboard(QWidget): self.cards = {} self.titles = [ - "CPU", "RAM", "Disk", "Uptime", - "CPU Temp", "GPU Temp", "GPU Usage", "Swap", - "Download", "Upload", "Alive", "Processes" + {"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"}, ] # ๋ฉ”์ธ ๋ ˆ์ด์•„์›ƒ @@ -25,16 +35,16 @@ class Dashboard(QWidget): # ์นด๋“œ ๊ทธ๋ฆฌ๋“œ self.grid = QGridLayout() - self.grid.setSpacing(10) + self.grid.setContentsMargins(0, 0, 0, 0) # (left, top, right, bottom) + self.grid.setSpacing(5) self.layout.addLayout(self.grid) - # ์นด๋“œ ์ƒ์„ฑ - for i, title in enumerate(self.titles): + for i, item in enumerate(self.titles): row = i // 4 col = i % 4 - card = MonitorCard(title) + card = MonitorCard(item['title'], bg_color=item['bg_color']) self.grid.addWidget(card, row, col) - self.cards[title] = card + self.cards[item['id']] = card # โœ… ์˜ฌ๋ฐ”๋ฅธ ํ‚ค ๋“ฑ๋ก # ์˜ค๋ฒ„๋ ˆ์ด ์ƒ์„ฑ self.overlay = LoadingOverlay(self) @@ -54,12 +64,29 @@ class Dashboard(QWidget): def update_data(self): data = get_monitor_data() - for key in self.titles: - self.cards[key].update_value(data.get(key, "--")) + for item in self.titles: + value = data.get(item['id'], "--") + self.cards[item['id']].update_value(value) if __name__ == "__main__": app = QApplication(sys.argv) + dashboard = Dashboard() - dashboard.show() + # dashboard.show() + # ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ชจ๋‹ˆํ„ฐ ๋ชฉ๋ก ๊ฐ€์ ธ์˜ค๊ธฐ + screens = QGuiApplication.screens() + print("์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ชจ๋‹ˆํ„ฐ ์ˆ˜:", len(screens)) + + # ์˜ˆ: ๋‘ ๋ฒˆ์งธ ๋ชจ๋‹ˆํ„ฐ ์„ ํƒ (์ธ๋ฑ์Šค 1) + target_screen_index = 1 if len(screens) > 1 else 0 + target_screen = screens[target_screen_index] + + # ์„ ํƒํ•œ ๋ชจ๋‹ˆํ„ฐ์˜ geometry๋กœ ์ด๋™ + geometry = target_screen.geometry() + dashboard.setGeometry(geometry) + + # ์ „์ฒดํ™”๋ฉด์œผ๋กœ ํ‘œ์‹œ + dashboard.showFullScreen() + sys.exit(app.exec()) diff --git a/qtDash/monitor_card.py b/qtDash/monitor_card.py index 2fa8ffa..aabaf86 100644 --- a/qtDash/monitor_card.py +++ b/qtDash/monitor_card.py @@ -11,14 +11,14 @@ class MonitorCard(QWidget): border-radius: 10px; border: 1px solid #444; """) - layout = QVBoxLayout() + layout = QVBoxLayout() self.title = QLabel(title) - self.title.setStyleSheet("font-weight: bold; font-size: 16px; color: white;") + self.title.setStyleSheet("font-weight: bold; font-size: 50px; color: white;") self.title.setAlignment(Qt.AlignmentFlag.AlignCenter) self.value = QLabel("--") - self.value.setStyleSheet("font-size: 24px; font-weight: bold; color: white;") + self.value.setStyleSheet("font-size: 40px; font-weight: bold; color: white;") self.value.setAlignment(Qt.AlignmentFlag.AlignCenter) self.spinner = QLabel() diff --git a/qtDash/monitor_data.py b/qtDash/monitor_data.py index 3cdddc6..822cab9 100644 --- a/qtDash/monitor_data.py +++ b/qtDash/monitor_data.py @@ -58,17 +58,16 @@ def check_alive(ip="192.168.0.101"): def get_monitor_data(): download, upload = get_net_speed() return { - "CPU": f"{psutil.cpu_percent()}%", - "RAM": f"{psutil.virtual_memory().percent}%", - "Disk": f"{psutil.disk_usage('/').percent}%", - "Uptime": format_uptime(), - "CPU Temp": get_cpu_temp(), - "GPU Temp": get_gpu_temp(), - "GPU Usage": get_gpu_usage(), - "Swap": f"{psutil.swap_memory().percent}%", - "Download": download, - "Upload": upload, - "Alive": check_alive(), - "Processes": str(len(psutil.pids())) + "cpu": f"{psutil.cpu_percent()}%", + "ram": f"{psutil.virtual_memory().percent}%", + "disk": f"{psutil.disk_usage('/').percent}%", + "uptime": format_uptime(), + "cpu_temp": get_cpu_temp(), + "gpu_temp": get_gpu_temp(), + "gpu_usage": get_gpu_usage(), + "swap": f"{psutil.swap_memory().percent}%", + "download": download, + "upload": upload, + "alive": check_alive(), + "processes": str(len(psutil.pids())) } - diff --git a/qtDash/t.py b/qtDash/t.py deleted file mode 100644 index 9535078..0000000 --- a/qtDash/t.py +++ /dev/null @@ -1,32 +0,0 @@ -# main.py -# main.py -from PyQt6.QtWidgets import QApplication, QWidget, QGridLayout -from PyQt6.QtCore import QTimer -import sys -from monitor_data import get_monitor_data -from monitor_card import MonitorCard # ์นด๋“œ UI๋Š” ๋”ฐ๋กœ ๋ถ„๋ฆฌํ•ด๋„ ์ข‹์Œ - -from loading_overlay import LoadingOverlay - -class Dashboard(QWidget): - def __init__(self): - super().__init__() - self.init_ui() - - def init_ui(self): - # ์นด๋“œ๋“ค ๋ฐฐ์น˜ - self.layout = QVBoxLayout(self) - self.setLayout(self.layout) - - # ์˜ค๋ฒ„๋ ˆ์ด ์ƒ์„ฑ - self.overlay = LoadingOverlay(self) - - # ๋กœ๋”ฉ ์‹œ์ž‘ - self.overlay.start() - - # ๋ฐ์ดํ„ฐ ์ˆ˜์‹  ํ›„ - QTimer.singleShot(2000, self.finish_loading) - - def finish_loading(self): - self.overlay.stop() - # ์นด๋“œ๋“ค์— ๊ฐ’ ์—…๋ฐ์ดํŠธ