74 lines
2.6 KiB
Python
74 lines
2.6 KiB
Python
from PyQt6.QtWidgets import (
|
|
QApplication, QWidget, QGridLayout, QLabel, QVBoxLayout
|
|
)
|
|
from PyQt6.QtCore import Qt, QTimer
|
|
import sys
|
|
|
|
class MonitorCard(QWidget):
|
|
def __init__(self, title, bg_color="#2e2e2e"):
|
|
super().__init__()
|
|
self.setStyleSheet(f"background-color: {bg_color}; border-radius: 10px;")
|
|
layout = QVBoxLayout()
|
|
self.title = QLabel(title)
|
|
self.title.setStyleSheet("font-weight: bold; font-size: 16px; color: white;")
|
|
self.value = QLabel("--")
|
|
self.value.setStyleSheet("font-size: 24px; font-weight: bold; color: white;")
|
|
self.title.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
self.value.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
layout.addWidget(self.title)
|
|
layout.addWidget(self.value)
|
|
self.setLayout(layout)
|
|
|
|
def update_value(self, text):
|
|
self.value.setText(text)
|
|
|
|
class Dashboard(QWidget):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.setWindowTitle("Server Monitor Dashboard")
|
|
self.setFixedSize(960, 640)
|
|
self.grid = QGridLayout()
|
|
self.grid.setSpacing(10)
|
|
|
|
self.cards = {}
|
|
titles = [
|
|
"CPU", "RAM", "Disk", "Uptime",
|
|
"CPU Temp", "GPU Temp", "GPU Usage", "Swap",
|
|
"Download", "Upload", "Alive", "Processes"
|
|
]
|
|
|
|
for i, title in enumerate(titles):
|
|
row = i // 4
|
|
col = i % 4
|
|
card = MonitorCard(title)
|
|
self.grid.addWidget(card, row, col)
|
|
self.cards[title] = card
|
|
|
|
self.setLayout(self.grid)
|
|
|
|
# 타이머로 데이터 갱신 예정
|
|
self.timer = QTimer()
|
|
self.timer.timeout.connect(self.update_data)
|
|
self.timer.start(3000)
|
|
|
|
def update_data(self):
|
|
# 여기서 psutil 등으로 실제 데이터를 가져와서 업데이트
|
|
self.cards["CPU"].update_value("15%")
|
|
self.cards["RAM"].update_value("42%")
|
|
self.cards["Disk"].update_value("68%")
|
|
self.cards["Uptime"].update_value("2d 04h 12m")
|
|
self.cards["CPU Temp"].update_value("54°C")
|
|
self.cards["GPU Temp"].update_value("48°C")
|
|
self.cards["GPU Usage"].update_value("23%")
|
|
self.cards["Swap"].update_value("12%")
|
|
self.cards["Download"].update_value("1.2 MB/s")
|
|
self.cards["Upload"].update_value("0.8 MB/s")
|
|
self.cards["Alive"].update_value("True")
|
|
self.cards["Processes"].update_value("142")
|
|
|
|
if __name__ == "__main__":
|
|
app = QApplication(sys.argv)
|
|
dashboard = Dashboard()
|
|
dashboard.show()
|
|
sys.exit(app.exec())
|