jit imports
This commit is contained in:
parent
c3d70b4c76
commit
c5339f95e9
9
Car.py
9
Car.py
@ -1,12 +1,15 @@
|
||||
import sumolib
|
||||
from math import dist, ceil, sqrt, log, cos, sin, atan2, pi
|
||||
from random import randint, uniform
|
||||
from PySide6.QtGui import QPainter, QColor
|
||||
from PySide6.QtCore import QPointF, Signal, QObject, Qt
|
||||
from itertools import islice
|
||||
import time
|
||||
import globalImport
|
||||
|
||||
class updateSignals(QObject):
|
||||
def pysideImports():
|
||||
globalImport("PySide6.QtGui", ["QPainter", "QColor"])
|
||||
globalImport("PySide6.QtCore", ["QPointF", "Signal", "QObject", "Qt"])
|
||||
|
||||
class updateSignals(QObject):
|
||||
updateDisp = Signal(tuple)
|
||||
addGraphPt = Signal(tuple)
|
||||
|
||||
|
@ -1,15 +1,18 @@
|
||||
import sumolib
|
||||
from Car import Car
|
||||
from Flow import Flow
|
||||
from carInfo import Ui_carInfo
|
||||
from varEdit import Ui_varEdit
|
||||
from PySide6.QtWidgets import QWidget, QLabel, QToolBox
|
||||
from PySide6.QtCore import Qt, Slot, Signal, QThread
|
||||
from PySide6.QtCharts import QChart, QSplineSeries, QLineSeries
|
||||
from PySide6.QtGui import QColor
|
||||
from math import ceil, dist
|
||||
import globalImport
|
||||
|
||||
class carInfo(QWidget):
|
||||
def pysideImports():
|
||||
globalImport("carInfo", "Ui_carInfo")
|
||||
globalImport("varEdit", "Ui_varEdit")
|
||||
globalImport("PySide6.QtWidgets", ["QWidget, QLabel, QToolBox"])
|
||||
globalImport("PySide6.QtCore", ["Qt", "Slot", "Signal", "QThread"])
|
||||
globalImport("PySide6.QtCharts", ["QChart", "QSplineSeries", "QLineSeries"])
|
||||
globalImport("PySide6.QtGui", ["QColor"])
|
||||
|
||||
class carInfo(QWidget):
|
||||
def __init__(self,parent):
|
||||
super().__init__()
|
||||
self.ui = Ui_carInfo()
|
||||
@ -77,7 +80,7 @@ class carInfo(QWidget):
|
||||
obj.setText(f"{key} : {val}")
|
||||
obj.update()
|
||||
|
||||
class varEdit(QWidget):
|
||||
class varEdit(QWidget):
|
||||
def __init__(self, parent, carController, varName, value):
|
||||
super().__init__()
|
||||
self.ui = Ui_varEdit()
|
||||
@ -116,6 +119,8 @@ class CarController:
|
||||
self.vroomEnable=True
|
||||
|
||||
def addParent(self, mainWindow):
|
||||
pysideImports()
|
||||
|
||||
self.infoWidget=mainWindow.findChild(QToolBox, "carInfos")
|
||||
|
||||
varWidget = mainWindow.ui.constEdit
|
||||
|
13
Map.py
13
Map.py
@ -3,8 +3,16 @@
|
||||
# mais si on se decide à utiliser notre propre format dans le futur ça facilitera la transition
|
||||
|
||||
import sumolib
|
||||
from PySide6.QtGui import QPainter, QPolygonF
|
||||
from PySide6.QtCore import Qt, QPointF, QThread
|
||||
import globalImport
|
||||
|
||||
imported = False
|
||||
|
||||
def pysideImports():
|
||||
if imported:
|
||||
return
|
||||
globalImport("PySide6.QtGui", ["QPainter", "QPolygonF"])
|
||||
globalImport("PySide6.QtCore", ["Qt", "QPointF", "QThread"])
|
||||
imported = True
|
||||
|
||||
def safeCall(func):
|
||||
def inner(*args, **kwargs):
|
||||
@ -29,6 +37,7 @@ class Map:
|
||||
|
||||
@safeCall
|
||||
def draw(self, painter):
|
||||
pysideImports()
|
||||
for edge in self.net.getEdges():
|
||||
color=Qt.white
|
||||
if(edge.getFunction()=="internal"):
|
||||
|
8
globalImport.py
Normal file
8
globalImport.py
Normal file
@ -0,0 +1,8 @@
|
||||
def globalImport(namespace, childrens=None):
|
||||
if childrens is None:
|
||||
globals()[namespace] = __import__(namespace)
|
||||
elif isinstance(childrens, str):
|
||||
globals()[namespace] = __import__(f"{namespace}.{childrens}")
|
||||
else:
|
||||
for c in childrens:
|
||||
globals()[c] = __import__(f"{namespace}.{c}")
|
Loading…
x
Reference in New Issue
Block a user