-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathmain_window.py
39 lines (31 loc) · 1.18 KB
/
main_window.py
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
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()