from PyQt6.QtCore import QObject, pyqtSlot from time import time class Controller(QObject): def __init__(self, window, screen, max_scene, parent=None): super().__init__(parent) self.window = window self.last_close_press = 0 self.successful_clicks = 0 self.screen = screen self.max_scene = max_scene @pyqtSlot() def close_application(self): now = time() if now - self.last_close_press < 0.2: self.successful_clicks += 1 else: self.successful_clicks = 0 if self.successful_clicks > 1: self.window.running = False self.last_close_press = now @pyqtSlot(int) def select_scene(self, scene: int): if scene >= self.max_scene: return self.screen.last_scene = self.screen.active_scene self.screen.active_scene = scene self.screen.scene_time = 0