forked from UTSAVS26/PyVerse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.py
More file actions
56 lines (50 loc) · 2.4 KB
/
Copy pathdashboard.py
File metadata and controls
56 lines (50 loc) · 2.4 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import sys
def run_dashboard(mode='qt'):
if mode == 'qt':
try:
from PyQt5.QtWidgets import QApplication, QMainWindow, QTabWidget, QWidget, QVBoxLayout, QLabel
except ImportError:
print("PyQt5 is not installed. Please install it with 'pip install pyqt5'.")
sys.exit(1)
class DashboardWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Dynamic Hardware Resource Monitor")
self.setGeometry(100, 100, 1000, 700)
self.tabs = QTabWidget()
self.setCentralWidget(self.tabs)
self.init_tabs()
def init_tabs(self):
self.tabs.addTab(self._make_tab("CPU Usage"), "CPU")
self.tabs.addTab(self._make_tab("Memory Usage"), "Memory")
self.tabs.addTab(self._make_tab("GPU Usage"), "GPU")
self.tabs.addTab(self._make_tab("Disk I/O"), "Disk")
self.tabs.addTab(self._make_tab("Network I/O"), "Network")
self.tabs.addTab(self._make_tab("Prediction"), "Prediction")
def _make_tab(self, label_text):
tab = QWidget()
layout = QVBoxLayout()
label = QLabel(label_text)
layout.addWidget(label)
tab.setLayout(layout)
return tab
app = QApplication(sys.argv if not QApplication.instance() else [])
window = DashboardWindow()
window.show()
return app
elif mode == 'web':
try:
try:
- import streamlit as st
+ import importlib.util
+ if not importlib.util.find_spec("streamlit"):
+ raise ImportError("Streamlit is not installed")
except ImportError:
- raise ImportError("Streamlit is not installed. Please install it with 'pip install streamlit'.")
+ raise ImportError("Streamlit is not installed. Please install it with 'pip install streamlit'.") from None
# Note: Streamlit apps should be run with `streamlit run script.py`
# This function should create a Streamlit script file or use subprocess
print("To run in web mode, use: streamlit run <streamlit_script.py>")
print("Web dashboard functionality needs to be implemented in a separate Streamlit script.")
else:
print(f"Unknown mode: {mode}")