-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
57 lines (44 loc) · 1.77 KB
/
main.py
File metadata and controls
57 lines (44 loc) · 1.77 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
57
# main.py
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QStackedWidget
from windows.login_window import LoginWindow
from windows.new_account_window import NewAccountWindow
from windows.main_window import MainWindow
class MainApp(QMainWindow):
def __init__(self):
super(MainApp, self).__init__()
self.stack = QStackedWidget()
self.setCentralWidget(self.stack)
self.init_app_settings()
self.show_login_window()
def show_login_window(self):
self.login_window = LoginWindow(self)
self.stack.addWidget(self.login_window)
self.stack.setCurrentWidget(self.login_window)
def show_new_account_window(self):
self.new_account_window = NewAccountWindow(self)
self.stack.addWidget(self.new_account_window)
self.stack.setCurrentWidget(self.new_account_window)
def show_main_window(self, username_in):
self.main_window = MainWindow(self, username_in)
self.stack.addWidget(self.main_window)
self.stack.setCurrentWidget(self.main_window)
def init_app_settings(self):
title = "Wirtualny trener personalny"
min_window_width = 1200
min_window_height = 800
self.setWindowTitle(title)
self.setMinimumSize(min_window_width, min_window_height)
def closeEvent(self, event):
current_widget = self.stack.currentWidget()
if isinstance(current_widget, MainWindow):
current_page = current_widget.stacked_main_window.currentWidget()
if hasattr(current_page, 'stop_training_if_any'):
current_page.stop_training_if_any()
def main():
app = QApplication(sys.argv)
main_window = MainApp()
main_window.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()