diff --git a/main.py b/main.py index 7b66001..cd5b025 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,8 @@ import os, sys -import time if 'SUMO_HOME' in os.environ: tools = os.path.join(os.environ['SUMO_HOME'], 'tools') sys.path.append(tools) -else: +else: print("please declare environment variable 'SUMO_HOME'") from PySide6.QtCore import Qt, QTimer @@ -15,7 +14,7 @@ from mainLoop import mainLoop class MainWindow(QMainWindow): def __init__(self): - super(MainWindow, self).__init__() + super().__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) @@ -30,16 +29,16 @@ class MainWindow(QMainWindow): openNet.setStatusTip("Open Network file (.net.xml)") openNet.triggered.connect(self.mainLoop.openNetwork) openMenu.addAction(openNet) - + openVeh = QAction("&Open Vehicles",self) openVeh.setStatusTip("Open Vehicle description (.rou.xml)") openVeh.triggered.connect(self.mainLoop.openVehicles) openMenu.addAction(openVeh) timer = QTimer(self) - timer.timeout.connect(self.mainLoop.update) + timer.timeout.connect(self.ui.mainSurf.update) timer.start(1.0/60) - + def keyPressEvent(self, e): if e.key() == Qt.Key_Escape or e.key() == Qt.Key_Q: self.close() @@ -49,13 +48,13 @@ class MainWindow(QMainWindow): if __name__ == "__main__": app = QApplication() - - format = QSurfaceFormat() - format.setDepthBufferSize(24) - format.setVersion(3, 2) - format.setSamples(4) - format.setProfile(QSurfaceFormat.CoreProfile) - QSurfaceFormat.setDefaultFormat(format) + + f = QSurfaceFormat() + f.setDepthBufferSize(24) + f.setVersion(3, 2) + f.setSamples(4) + f.setProfile(QSurfaceFormat.CoreProfile) + QSurfaceFormat.setDefaultFormat(f) window = MainWindow() window.show() diff --git a/mainLoop.py b/mainLoop.py index bb5021f..4fd56ae 100644 --- a/mainLoop.py +++ b/mainLoop.py @@ -10,19 +10,18 @@ class mainLoop(): self.painter = parent.ui.mainSurf self.map = Map() - + self.controller = CarController(self.map) - + self.painter.addMap(self.map) self.painter.addCarController(self.controller) def update(self): self.controller.update() - self.painter.update() def openNetwork(self): fileName = QFileDialog.getOpenFileName(self.parent,"Open Network", "./", "Network File (*.net.xml)") - if(fileName[0] == ''): + if fileName[0] == '': return self.map.fromPath(fileName[0]) self.painter.generateTransform() @@ -31,10 +30,10 @@ class mainLoop(): def openVehicles(self): fileName = QFileDialog.getOpenFileName(self.parent,"Open Vehicle trip description", "./", "Route File (*.rou.xml)") - if(fileName[0] == ''): + if fileName[0] == '': return self.controller.fromPath(fileName[0]) - if(self.map.isLoaded()): + if self.map.isLoaded(): self.controller.prepareRoute() def quickLoad(self):