IRESTE/main.py
2022-02-17 21:00:43 +01:00

63 lines
1.7 KiB
Python

import os, sys
if 'SUMO_HOME' in os.environ:
tools = os.path.join(os.environ['SUMO_HOME'], 'tools')
sys.path.append(tools)
else:
print("please declare environment variable 'SUMO_HOME'")
from PySide6.QtCore import Qt, QTimer
from PySide6.QtWidgets import QApplication, QMainWindow
from PySide6.QtGui import QSurfaceFormat, QAction
from window import Ui_MainWindow
from mainLoop import mainLoop
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.mainLoop = mainLoop(self)
self.mainLoop.addInfosDisplay(self.ui.infos)
fileMenu = self.menuBar().addMenu("&File")
openMenu = fileMenu.addMenu("&Open")
openNet = QAction("&Open Network",self)
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.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()
elif e.key() == Qt.Key_S:
self.mainLoop.quickLoad()
if __name__ == "__main__":
app = QApplication()
f = QSurfaceFormat()
f.setDepthBufferSize(24)
f.setVersion(3, 2)
f.setSamples(4)
f.setProfile(QSurfaceFormat.CoreProfile)
QSurfaceFormat.setDefaultFormat(f)
window = MainWindow()
window.show()
sys.exit(app.exec())