62 lines
1.8 KiB
Python
62 lines
1.8 KiB
Python
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:
|
|
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(MainWindow, self).__init__()
|
|
self.ui = Ui_MainWindow()
|
|
self.ui.setupUi(self)
|
|
|
|
self.setAttribute(Qt.WA_TranslucentBackground)
|
|
self.setAttribute(Qt.WA_NoSystemBackground, False)
|
|
|
|
self.mainLoop = mainLoop(self)
|
|
|
|
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.mainLoop.update)
|
|
timer.start(1.0/60)
|
|
|
|
def keyPressEvent(self, e):
|
|
if e.key() == Qt.Key_Escape or e.key() == Qt.Key_Q:
|
|
self.close()
|
|
|
|
if __name__ == "__main__":
|
|
app = QApplication()
|
|
|
|
format = QSurfaceFormat()
|
|
format.setDepthBufferSize(24)
|
|
format.setVersion(3, 2)
|
|
format.setSamples(4)
|
|
format.setProfile(QSurfaceFormat.CoreProfile)
|
|
QSurfaceFormat.setDefaultFormat(format)
|
|
|
|
window = MainWindow()
|
|
window.show()
|
|
|
|
sys.exit(app.exec())
|