-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.py
73 lines (57 loc) · 2.33 KB
/
mainwindow.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from PySide6.QtWidgets import QMainWindow,QStatusBar, QGridLayout,QVBoxLayout,QHBoxLayout, QSlider, QLabel, QWidget
from PySide6.QtGui import QAction,QScreen
from PySide6.QtCore import *
from portwindow import PortWindow
from eventwindow import EventWindow
from centralwidget import CentralWidget
from modbus import Modbus
class MainWindow(QMainWindow):
def __init__(self,app,modbus,width,height):
super().__init__()
self.app = app # declare an app member
self.setWindowTitle("Floppster - Roasting Dumminess")
self.setGeometry(0,0,width,height)
self.modbus = modbus
#actions
port_action = QAction("Port",self)
port_action.setStatusTip("Opens Port Configuration Window")
port_action.triggered.connect(self.open_port_window)
event_action = QAction("Event",self)
event_action.setStatusTip("Opens Event Configuration Window")
event_action.triggered.connect(self.open_event_window)
#Menu bar
menu_bar = self.menuBar()
#file menu
file_menu = menu_bar.addMenu("File")
quit_action = file_menu.addAction("Quit")
quit_action.triggered.connect(self.quit_app)
#edit menu
edit_menu = menu_bar.addMenu("Edit")
#config menu
config_menu = menu_bar.addMenu("Config")
self.port_window = None
config_menu.addAction(port_action)
self.event_window = None
config_menu.addAction(event_action)
#status bar
self.setStatusBar(QStatusBar(self))
#main panel layout
central_widget = CentralWidget(self.modbus)
self.setCentralWidget(central_widget)
self.show()
def open_port_window(self, checked):
if self.port_window is None:
self.port_window = PortWindow(self.modbus)
self.port_window.show()
else:
self.port_window.close() # Close window.
self.port_window = None # Discard reference.
def open_event_window(self, checked):
if self.event_window is None:
self.event_window = EventWindow()
self.event_window.show()
else:
self.event_window.close() # Close window.
self.event_window = None # Discard reference.
def quit_app(self):
self.app.quit()