| |
| """ |
| Main Application for GPU Floating Monitor |
| Integrates GPU data reader with floating UI |
| """ |
|
|
| import sys |
| import time |
| from PyQt6.QtWidgets import QApplication |
| from PyQt6.QtCore import QTimer |
| from gpu_reader import GPUReader |
| from ui import FloatingWindow |
|
|
| class GPUMonitorApp: |
| def __init__(self, update_interval=1000): |
| self.app = QApplication(sys.argv) |
| self.reader = GPUReader() |
| self.window = FloatingWindow() |
| self.update_interval = update_interval |
| |
| |
| self.timer = QTimer() |
| self.timer.timeout.connect(self.update_display) |
| self.timer.start(self.update_interval) |
| |
| def update_display(self): |
| """Update the display with latest GPU data""" |
| try: |
| data = self.reader.get_all_data() |
| self.window.update_data(data) |
| except Exception as e: |
| print(f"Error updating display: {e}") |
| |
| def run(self): |
| """Run the application""" |
| |
| self.window.show() |
| |
| |
| self.update_display() |
| |
| |
| return self.app.exec() |
|
|
| def main(): |
| |
| app = GPUMonitorApp() |
| sys.exit(app.run()) |
|
|
| if __name__ == "__main__": |
| main() |