本文整理汇总了Python中PyQt4.QtCore.QTimeLine类的典型用法代码示例。如果您正苦于以下问题:Python QTimeLine类的具体用法?Python QTimeLine怎么用?Python QTimeLine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QTimeLine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FaderWidget
class FaderWidget(QWidget):
def __init__(self, old_widget, new_widget):
QWidget.__init__(self, new_widget)
self.old_pixmap = QPixmap(new_widget.size())
old_widget.render(self.old_pixmap)
self.pixmap_opacity = 1.0
self.timeline = QTimeLine()
self.timeline.valueChanged.connect(self.animate)
self.timeline.finished.connect(self.close)
self.timeline.setDuration(500)
self.timeline.start()
self.resize(new_widget.size())
self.show()
def paintEvent(self, event):
painter = QPainter()
painter.begin(self)
painter.setOpacity(self.pixmap_opacity)
painter.drawPixmap(0, 0, self.old_pixmap)
painter.end()
def animate(self, value):
self.pixmap_opacity = 1.0 - value
self.repaint()
示例2: __init__
def __init__(self):
QGraphicsView.__init__(self)
self.ofs = 0
self.factor = 1
self.scene = QGraphicsScene()
self.background = None
self.icons = []
self.iconTimeLine = QTimeLine()
self.backgroundTimeLine = QTimeLine()
self.setScene(self.scene)
self.background = self.scene.addPixmap(QPixmap(":/background.jpg"))
self.background.setZValue(0.0)
self.background.setPos(0, 0)
for i in range(7):
str = QString(":/icon%1.png").arg(i+1)
icon = self.scene.addPixmap(QPixmap(str))
icon.setPos(320+i*64, 400)
icon.setZValue(1.0)
self.icons.append(icon)
self.setFixedSize(320, 480)
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.connect(self.iconTimeLine, SIGNAL("frameChanged(int)"), self, SLOT("moveIcons(int)"))
self.iconTimeLine.setCurveShape(QTimeLine.EaseInOutCurve)
self.connect(self.backgroundTimeLine, SIGNAL("frameChanged(int)"), self, SLOT("moveBackground(int)"))
self.connect(self.backgroundTimeLine, SIGNAL("finished()"), self, SLOT("adjustParameters()"))
self.backgroundTimeLine.setCurveShape(QTimeLine.EaseInOutCurve)
self.controls = Ui_ControlsForm()
toolWidget = QWidget(self)
toolWidget.setWindowFlags(Qt.Tool | Qt.WindowTitleHint)
self.controls.setupUi(toolWidget)
toolWidget.show()
self.connect(self.controls.speedSlider, SIGNAL("valueChanged(int)"),
self, SLOT("adjustParameters()"))
self.connect(self.controls.normalButton, SIGNAL("clicked()"),
self, SLOT("adjustParameters()"))
self.connect(self.controls.parallaxButton, SIGNAL("clicked()"),
self, SLOT("adjustParameters()"))
self.connect(self.controls.leftButton, SIGNAL("clicked()"),
self, SLOT("slideLeft()"))
self.connect(self.controls.rightButton, SIGNAL("clicked()"),
self, SLOT("slideRight()"))
self.slideBy(-320)
self.adjustParameters()
示例3: Joystick
class Joystick(Button):
def __init__(self, outer, inner, 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.outer = outer
self.inner = inner
self.innerRange = 48
self.inputRange = 256
self.thresh = 5
self.outerCircle = QGraphicsEllipseItem(self.getX(), self.getY(), self.outer, self.outer)
self.outerCircle.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.outerCircle.setBrush(Qt.gray)
self.innerCircle = QGraphicsEllipseItem(self.getX() + self.outer / 2 - self.inner / 2, self.getY() + self.outer / 2 - self.inner / 2, self.inner, self.inner)
self.innerCircle.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.innerCircle.setBrush(Qt.lightGray)
self.currentX = 0
self.currentY = 0
self.items = [self.outerCircle, self.innerCircle]
def getItems(self):
return self.items
def setScene(self, scene):
self.scene = scene
for item in self.items :
self.scene.addItem(item)
def update(self,x,y,z):
# y = y - sqrt(x + y) if x > 0 else y
# x = x - sqrt(x + y) if y > 0 else x
x2 = x * self.innerRange / self.inputRange - self.innerRange / 2
y2 = y * self.innerRange / self.inputRange - self.innerRange / 2
x2 = x2 - sqrt(abs(y2)) if x2 >= 0 else x2 + sqrt(abs(y2))
y2 = y2 - sqrt(abs(x2)) if y2 >= 0 else y2 + sqrt(abs(x2))
if self.inputRange / 2 - self.thresh <= x <= self.inputRange / 2 + self.thresh:
x2 = 0
if self.inputRange / 2 - self.thresh <= y <= self.inputRange / 2 + self.thresh:
y2 = 0
self.tl = QTimeLine(10)
self.tl.setFrameRange(0, 10)
self.a = QGraphicsItemAnimation()
self.a.setItem(self.innerCircle)
self.a.setTimeLine(self.tl)
self.a.setPosAt(0, QPointF(self.currentX, self.currentY))
self.a.setTranslationAt(1, x2, y2)
if z:
self.innerCircle.setPen(QPen(QColor(Qt.white), 1, Qt.SolidLine))
self.innerCircle.setBrush(QColor(200, 225, 3))
else:
self.innerCircle.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.innerCircle.setBrush(Qt.lightGray)
self.currentX = x2
self.currentY = y2
self.tl.start()
示例4: SingleJoystickView
class SingleJoystickView(QGraphicsView):
def __init__(self, *args):
QGraphicsView.__init__(self, *args)
self.outerD = 125
self.innerD = 25
self.innerRange = 50
self.inputRange = 256
self.thresh = 3
self.worker = JoystickThread()
self.worker.valueUpdated.connect(self.moveJoystick)
self.worker.start()
self.move(30, 100)
self.setContentsMargins(0, 0, 0, 0)
self.setMaximumHeight(140)
self.setMaximumWidth(140)
self.adjustSize()
self.scene = QGraphicsScene(self)
self.outerCircle = QGraphicsEllipseItem(0, 0, self.outerD, self.outerD)
self.outerCircle.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.outerCircle.setBrush(Qt.gray)
self.innerCircle = QGraphicsEllipseItem(self.outerD / 2 - self.innerD / 2, self.outerD / 2 - self.innerD / 2, self.innerD, self.innerD)
self.innerCircle.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.innerCircle.setBrush(Qt.lightGray)
self.scene.addItem(self.outerCircle)
self.scene.addItem(self.innerCircle)
self.setScene(self.scene)
self.setStyleSheet('background-color:transparent;color:red')
self.currentX = 0
self.currentY = 0
def moveJoystick(self, x, y):
x2 = x * self.innerRange / self.inputRange - self.innerRange / 2
y2 = y * self.innerRange / self.inputRange - self.innerRange / 2
if -self.thresh <= x2 <= self.thresh:
x2 = 0
if -self.thresh <= y2 <= self.thresh:
y2 = 0
self.tl = QTimeLine(10)
self.tl.setFrameRange(0, 10)
self.a = QGraphicsItemAnimation()
self.a.setItem(self.innerCircle)
self.a.setTimeLine(self.tl)
self.a.setPosAt(0, QPointF(self.currentX, self.currentY))
self.a.setTranslationAt(1, x2, y2)
self.currentX = x2
self.currentY = y2
self.tl.start()
print 'x:%d y:%d' % (x2, y2)
示例5: update
def update(self,x,y,z):
# y = y - sqrt(x + y) if x > 0 else y
# x = x - sqrt(x + y) if y > 0 else x
x2 = x * self.innerRange / self.inputRange - self.innerRange / 2
y2 = y * self.innerRange / self.inputRange - self.innerRange / 2
x2 = x2 - sqrt(abs(y2)) if x2 >= 0 else x2 + sqrt(abs(y2))
y2 = y2 - sqrt(abs(x2)) if y2 >= 0 else y2 + sqrt(abs(x2))
if self.inputRange / 2 - self.thresh <= x <= self.inputRange / 2 + self.thresh:
x2 = 0
if self.inputRange / 2 - self.thresh <= y <= self.inputRange / 2 + self.thresh:
y2 = 0
self.tl = QTimeLine(10)
self.tl.setFrameRange(0, 10)
self.a = QGraphicsItemAnimation()
self.a.setItem(self.innerCircle)
self.a.setTimeLine(self.tl)
self.a.setPosAt(0, QPointF(self.currentX, self.currentY))
self.a.setTranslationAt(1, x2, y2)
if z:
self.innerCircle.setPen(QPen(QColor(Qt.white), 1, Qt.SolidLine))
self.innerCircle.setBrush(QColor(200, 225, 3))
else:
self.innerCircle.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.innerCircle.setBrush(Qt.lightGray)
self.currentX = x2
self.currentY = y2
self.tl.start()
示例6: __init__
def __init__(self, parent):
QWidget.__init__(self, parent)
self._timeline = QTimeLine(400, self)
self._blending_factor = 0.0
self.connect(self._timeline, SIGNAL("valueChanged(qreal)"),
self._triggerRepaint)
self.connect(self._timeline, SIGNAL("finished()"), SIGNAL("finished()"))
示例7: __init__
def __init__(self, *args):
QGraphicsView.__init__(self, *args)
self.move(20, 240)
self.outerD = 125
self.innerD = 35
self.innerRange = 48
self.inputRange = 256
self.thresh = 3
self.padding = 40
self.marginTop = 10
self.worker = QSixAxisThread()
self.worker.valueUpdated.connect(self.moveJoysticks)
self.worker.start()
self.setContentsMargins(0, 0, 0, 0)
self.setMaximumHeight(180)
self.setMaximumWidth(420)
self.setMinimumHeight(240)
self.setMinimumWidth(300)
self.adjustSize()
self.scene = QGraphicsScene(self)
self.outerCircle1 = QGraphicsEllipseItem(0, self.marginTop, self.outerD, self.outerD)
self.outerCircle1.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.outerCircle1.setBrush(Qt.gray)
self.innerCircle1 = QGraphicsEllipseItem(self.outerD / 2 - self.innerD / 2, self.outerD / 2 - self.innerD / 2 + self.marginTop, self.innerD, self.innerD)
self.innerCircle1.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.innerCircle1.setBrush(Qt.lightGray)
self.scene.addItem(self.outerCircle1)
self.scene.addItem(self.innerCircle1)
self.outerCircle2 = QGraphicsEllipseItem(self.outerD + self.padding, self.marginTop, self.outerD, self.outerD)
self.outerCircle2.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.outerCircle2.setBrush(Qt.gray)
self.innerCircle2 = QGraphicsEllipseItem(self.outerD + self.padding + self.outerD / 2 - self.innerD / 2, self.outerD / 2 - self.innerD / 2 + self.marginTop, self.innerD, self.innerD)
self.innerCircle2.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.innerCircle2.setBrush(Qt.lightGray)
self.scene.addItem(self.outerCircle2)
self.scene.addItem(self.innerCircle2)
self.setScene(self.scene)
self.setStyleSheet('background-color:transparent; border-width: 0px; border: 0px;')
self.currentX = 0
self.currentY = 0
self.currentA = 0
self.currentZ = 0
self.psBtn = QPixmap(os.getcwd() + '/../icons/bt_PS.png')
self.psBtn = self.psBtn.scaled(50, 50, Qt.KeepAspectRatio)
self.psItem = QGraphicsPixmapItem(self.psBtn)
self.psItem.setOffset(QPointF(self.outerD - 4, 0))
self.effect = QGraphicsDropShadowEffect()
self.effect.setOffset(0, 0)
self.effect.setBlurRadius(20)
self.effect.setColor(Qt.green)
self.psItem.setGraphicsEffect(self.effect)
self.scene.addItem(self.psItem)
self.tl2 = QTimeLine(10000)
self.tl2.setFrameRange(0, 10000)
self.c = QGraphicsItemAnimation()
self.c.setItem(self.psItem)
self.c.setTimeLine(self.tl2)
self.tl2.connect(self.tl2, SIGNAL('frameChanged(int)'), self.updateEffect)
self.effectd = 3
self.tl2.start()
示例8: Meterbar
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)
示例9: __init__
def __init__(self, parent = None, direction = "ltr", rtf = False):
""" Creates a new QPageWidget on given parent object.
parent: QWidget parent
direction: "ltr" -> Left To Right
"ttb" -> Top To Bottom
rtf: Return to first, if its True it flips to the first page
when next page requested at the last page
"""
# First initialize, QPageWidget is based on QScrollArea
QScrollArea.__init__(self, parent)
# Properties for QScrollArea
self.setFrameShape(QFrame.NoFrame)
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.setWidgetResizable(True)
# Main widget, which stores all Pages in it
self.widget = QWidget(self)
# Layout based on QBoxLayout which supports Vertical or Horizontal layout
if direction == "ltr":
self.layout = QBoxLayout(QBoxLayout.LeftToRight, self.widget)
self.__scrollBar = self.horizontalScrollBar()
self.__base_value = self.width
else:
self.layout = QBoxLayout(QBoxLayout.TopToBottom, self.widget)
self.__scrollBar = self.verticalScrollBar()
self.__base_value = self.height
self.layout.setSpacing(0)
self.layout.setMargin(0)
# Return to first
self.__return_to_first = rtf
# TMP_PAGE, its using as last page in stack
# A workaround for a QScrollArea bug
self.__tmp_page = Page(QWidget(self.widget))
self.__pages = [self.__tmp_page]
self.__current = 0
self.__last = 0
# Set main widget
self.setWidget(self.widget)
# Animation TimeLine
self.__timeline = QTimeLine()
self.__timeline.setUpdateInterval(2)
# Updates scrollbar position when frame changed
self.__timeline.frameChanged.connect(lambda x: self.__scrollBar.setValue(x))
# End of the animation
self.__timeline.finished.connect(self._animateFinished)
# Initialize animation
self.setAnimation()
self.setDuration()
示例10: __init__
class Animation:
def __init__(self, duration, component):
self.tl = QTimeLine(duration)
self.tl.setFrameRange(0, duration)
self.component = component
self.t = QGraphicsItemAnimation()
self.t.setItem(self.component.item)
self.t.setTimeLine(self.tl)
self.tl.connect(self.tl, SIGNAL('frameChanged(int)'), self.update)
self.tl.connect(self.tl, SIGNAL('finished()'), self.finished)
def start(self):
self.tl.stop()
self.tl.start()
def update(self):
pass
def finished(self):
pass
示例11: __init__
def __init__(self, stackedWidget):
QWidget.__init__(self, stackedWidget)
self.curIndex = None
self.timeline = QTimeLine()
self.timeline.setDuration(333)
self.timeline.finished.connect(self.hide)
self.timeline.valueChanged.connect(self.animate)
stackedWidget.currentChanged.connect(self.start)
self.hide()
示例12: AnimatedGraphicsSvgItem
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)
示例13: test
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()
示例14: __init__
def __init__(self,resource,parent=None,steps=20,width=15,height=15):
QLabel.__init__(self,parent)
self._resource=resource
self._steps=steps
self._width=width
self._height=height
self._progressTimeLine = QTimeLine(1000, self)
self._progressTimeLine.setFrameRange(0, self._steps)
self._progressTimeLine.setLoopCount(0)
self.connect(self._progressTimeLine, SIGNAL("frameChanged(int)"), self.setProgress)
self._renderPixmaps()
self.setProgress(0)
示例15: __init__
def __init__(self, moveX=True, moveY=True, rect=QRectF(0, 0, 30, 30), parent=None):
super().__init__(parent)
self._movel = Movel(moveX, moveY, self)
self.installEventFilter(self._movel)
self._newPos = QPointF()
self._oldPos = QPointF()
self._rect = QRectF()
self._newRect = QRectF()
self._oldRect = QRectF()
self._timePos = QTimeLine(1000)
self._timePos.setCurveShape(QTimeLine.EaseInOutCurve)
self._timePos.valueChanged.connect(self._atualizaPos)
self._timeRect = QTimeLine(1000)
self._timeRect.valueChanged.connect(self._atualizaRect)
self.setTamanho(rect)