class Meterbar(Button):
    def __init__(self, max=255, filename=None, width=None, height=None, x=0, y=0, pixmap=None, group=None, pos=None, size=None, padding=None):
        Button.__init__(self, filename, width, height, x, y, pixmap, group, pos, size, padding)
        self.max = max
        self.outer = QGraphicsRectItem(x,y,width,max + 2)
        self.outer.setPen(QPen(QColor(Qt.black), 1, Qt.SolidLine))
        self.outer.setBrush(Qt.green)
#         self.outer.hide()
        self.inner = QGraphicsRectItem(x + 1,y + 1,width - 2,max)
        self.inner.setPen(QPen(QColor(Qt.green), 1, Qt.SolidLine))
        self.inner.setBrush(Qt.blue)
        self.items = [self.outer, self.inner]
        self.current = 255
        self.effect = QGraphicsDropShadowEffect()
        self.effect.setOffset(0, 0)
        self.effect.setBlurRadius(0)
        self.effect.setColor(Qt.green)
        self.item = self.outer
        self.addEffect('shadow', self.effect, True)
        self.addAnimation('glow', Glow(15, 300, self, maxRadius=80, minRadius=5))
#         self.test(10)
    
    def test(self, x):
        self.tl = QTimeLine(10000)
        self.tl.setFrameRange(0, 10000)
        self.a = QGraphicsItemAnimation()
        self.a.setItem(self.inner)
        self.a.setTimeLine(self.tl)
#         self.a.setPosAt(0, QPointF(self.getX(), self.current))
#         self.a.setTranslationAt(1, self.getX(), self.getY() + self.max - x + 1)
        self.a.setScaleAt(0, 1, 1)
        self.a.setScaleAt(1, 1, 0.1)
        self.current = x
        self.tl.start()
        
    def update(self, x):
        x2 = 1 - (float(x) * 1.0 / float(self.max))
#         print x
#         return
        self.tl = QTimeLine(10)
        self.tl.setFrameRange(0, 10)
        self.a = QGraphicsItemAnimation()
        self.a.setItem(self.inner)
        self.a.setTimeLine(self.tl)
#         self.a.setPosAt(0, QPointF(self.getX(), self.current))
#         self.a.setTranslationAt(1, self.getX(), self.getY() + self.max - x + 1)
        self.a.setScaleAt(0, 1, self.current)
        self.a.setScaleAt(1, 1, x2)
        self.current = x
        self.tl.start()
        if x > 3 :
            self.play('glow')
        
    def setScene(self, scene):
        self.scene = scene
        for item in self.items :
            self.scene.addItem(item)
示例#2
0
class AnimatedGraphicsSvgItem(QGraphicsSvgItem):
    def __init__(self, file, parent = None):
        QGraphicsSvgItem.__init__(self, file, parent)
        self.animation = QGraphicsItemAnimation()
        self.animation.setItem(self)
        self.timeline = QTimeLine(300)
        self.animation.setTimeLine(self.timeline)
    def setMatrix(self, matrix):
        self.matrix = matrix
        QGraphicsSvgItem.setMatrix(self, matrix)
    def show(self):
        self.scale(0.0, 0.0)
        self.animation.setPosAt(0.0, QPointF(self.matrix.dx()+self.boundingRect().width()/8, self.matrix.dy()+self.boundingRect().height()/8))
        self.animation.setPosAt(1.0, QPointF(self.matrix.dx(), self.matrix.dy()))
        self.animation.setScaleAt(0.0, 0.25, 0.25)
        self.animation.setScaleAt(1.0, 0.5, 0.5)
        self.timeline.start()
        QGraphicsSvgItem.show(self)
示例#3
0
class AnimatedGraphicsSvgItem(QGraphicsSvgItem):
    def __init__(self, file, parent=None):
        QGraphicsSvgItem.__init__(self, file, parent)
        self.animation = QGraphicsItemAnimation()
        self.animation.setItem(self)
        self.timeline = QTimeLine(300)
        self.animation.setTimeLine(self.timeline)

    def setMatrix(self, matrix):
        self.matrix = matrix
        QGraphicsSvgItem.setMatrix(self, matrix)

    def show(self):
        self.scale(0.0, 0.0)
        self.animation.setPosAt(
            0.0,
            QPointF(self.matrix.dx() + self.boundingRect().width() / 8,
                    self.matrix.dy() + self.boundingRect().height() / 8))
        self.animation.setPosAt(1.0, QPointF(self.matrix.dx(),
                                             self.matrix.dy()))
        self.animation.setScaleAt(0.0, 0.25, 0.25)
        self.animation.setScaleAt(1.0, 0.5, 0.5)
        self.timeline.start()
        QGraphicsSvgItem.show(self)