示例#1
0
 def addParticles(self, count: int):
     gen = QRandomGenerator()
     for i in range(count):
         # print(random(self.scene.width()))
         part = Particle(QPointF(gen.bounded(self.width()),\
             gen.bounded(self.height())))
         part.setVisible(False)
         self.addItem(part)
示例#2
0
    def __init__(self, pos: QPointF, **kwargs):
        """Constructor to create a particle, receives a QtVector2D and can \
        receive 'r' that is radius (float) and 'speed' that is speed (QVector2d)"""
        super().__init__()
        self.setPos(pos.x(), pos.y())

        self.rad = kwargs.get('r', 2)
        self.speed = kwargs.get('speed', QPointF(QRandomGenerator(randint(0,500)).bounded(-10,10),\
         QRandomGenerator(randint(0,500)).bounded(-10,10)))
示例#3
0
 def handleTimeout(self):
     x = self.plotArea().width() / self.axisX.tickCount()
     y = (self.axisX.max() - self.axisX.min()) / self.axisX.tickCount()
     self.m_x += y
     # 在PyQt5.11.3及以上版本中,QRandomGenerator.global()被重命名为global_()
     self.m_y = QRandomGenerator.global_().bounded(5) - 2.5
     self.series.append(self.m_x, self.m_y)
     self.scroll(x, 0)
     if self.m_x >= 100:
         self.timer.stop()
示例#4
0
    def handleTimeout(self):
        x = self.plotArea().width() / self.axisX.tickCount()
        y = (self.axisX.max() - self.axisX.min()) / self.axisX.tickCount()
        self.m_x += y

        # В PyQt 5.11.3 и выше, QRandomGenerator.global() был переименован в global_()
        try:
            self.m_y=db_wrk()
        except :
            self.m_y = QRandomGenerator.global_().bounded(50)
        self.series.append(self.m_x, self.m_y)
        self.scroll(x, 0)
        if self.m_x >= 10:
            self.timer.stop()