master-floor/ressult/run_gui.py
2025-11-26 19:31:33 +03:00

51 lines
1.6 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# run_gui.py
"""
Главный модуль запуска GUI приложения с авторизацией
"""
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from gui.login_window import LoginWindow
from gui.main_window import MainWindow
from PyQt6.QtWidgets import QApplication
from PyQt6.QtCore import QTimer
class ApplicationController:
"""Контроллер приложения, управляющий авторизацией и главным окном"""
def __init__(self):
self.app = QApplication(sys.argv)
self.login_window = None
self.main_window = None
self.current_user = None
def show_login(self):
"""Показать окно авторизации"""
self.login_window = LoginWindow()
self.login_window.login_success.connect(self.on_login_success)
self.login_window.show()
def on_login_success(self, user_data):
"""Обработка успешной авторизации"""
self.current_user = user_data
self.login_window.close()
self.show_main_window()
def show_main_window(self):
"""Показать главное окно приложения"""
self.main_window = MainWindow(self.current_user)
self.main_window.show()
def run(self):
"""Запуск приложения"""
self.show_login()
return self.app.exec()
def main():
"""Точка входа приложения"""
controller = ApplicationController()
sys.exit(controller.run())
if __name__ == "__main__":
main()