StreamingCommunity/gui/main_window.py
Francesco Grazioso 8b574f407f Refactor GUI code and modularize components
Splits the monolithic GUI logic into modular components, improving maintainability. Introduces `RunTab`, `ResultsTable`, and utility modules for better separation of concerns and reusability. Adjusts main entry point and refactors core functionalities to align with the new structure.
2025-02-25 15:42:14 +01:00

40 lines
1.2 KiB
Python

from PyQt5.QtWidgets import QMainWindow, QWidget, QVBoxLayout
from PyQt5.QtCore import QProcess
import sys
from .tabs.run_tab import RunTab
from .utils.stream_redirect import Stream
class StreamingGUI(QMainWindow):
def __init__(self):
super().__init__()
self.process = None
self.init_ui()
self.setup_output_redirect()
def init_ui(self):
self.setWindowTitle("StreamingCommunity GUI")
self.setGeometry(100, 100, 1000, 700)
central_widget = QWidget()
main_layout = QVBoxLayout()
self.run_tab = RunTab(self)
main_layout.addWidget(self.run_tab)
central_widget.setLayout(main_layout)
self.setCentralWidget(central_widget)
def setup_output_redirect(self):
self.stdout_stream = Stream()
self.stdout_stream.newText.connect(self.run_tab.update_output)
sys.stdout = self.stdout_stream
def closeEvent(self, event):
if self.process and self.process.state() == QProcess.Running:
self.process.terminate()
if not self.process.waitForFinished(1000):
self.process.kill()
sys.stdout = sys.__stdout__
event.accept()