本文整理汇总了Python中PyQt4.QtCore.QPropertyAnimation.setDuration方法的典型用法代码示例。如果您正苦于以下问题:Python QPropertyAnimation.setDuration方法的具体用法?Python QPropertyAnimation.setDuration怎么用?Python QPropertyAnimation.setDuration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QPropertyAnimation
的用法示例。
在下文中一共展示了QPropertyAnimation.setDuration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createAnimationFromToFor
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setDuration [as 别名]
def createAnimationFromToFor(widget, fromValue, toValue, duration, propName, curve=QEasingCurve.InOutCubic):
anim = QPropertyAnimation(widget, propName)
anim.setDuration(duration)
anim.setStartValue(fromValue)
anim.setEndValue(toValue)
anim.setEasingCurve(curve)
return anim
示例2: BaseDialog
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setDuration [as 别名]
class BaseDialog(QDialog):
""" Base para popup dialog en la esquina superior derecha """
def __init__(self, weditor):
super(BaseDialog, self).__init__(weditor)
self._weditor = weditor
self.line = None
# Popup
self.setWindowFlags(Qt.Popup)
# Posición
self.qpoint = weditor.rect().topRight()
self.global_point = weditor.mapToGlobal(self.qpoint)
# Animación
self._animation = QPropertyAnimation(self, "geometry")
self._animation.setDuration(150)
self._animation.setEasingCurve(QEasingCurve.Linear)
key_escape = QShortcut(QKeySequence(Qt.Key_Escape), self)
self.connect(key_escape, SIGNAL("activated()"), self._close)
def showEvent(self, event):
super(BaseDialog, self).showEvent(event)
x, y = self.geometry().x(), self.geometry().y()
self._animation.setStartValue(QRect(x, 0, self.width(), self.height()))
self._animation.setEndValue(QRect(x, y, self.width(), self.height()))
self._animation.start()
self.line.setFocus()
def _close(self):
x, y = self.geometry().x(), self.geometry().y()
self._animation.setStartValue(QRect(x, y, self.width(), self.height()))
self._animation.setEndValue(QRect(x, 0, self.width(), self.height()))
self._animation.start()
self.connect(self._animation, SIGNAL("finished()"), self.close)
示例3: _default__geo_animator
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setDuration [as 别名]
def _default__geo_animator(self):
""" Create the default property animator for the rubber band.
"""
p = QPropertyAnimation(self._band, 'geometry')
p.setDuration(self.band_geo_duration)
return p
示例4: _default__vis_animator
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setDuration [as 别名]
def _default__vis_animator(self):
""" Create the default property animator for the rubber band.
"""
p = QPropertyAnimation(self._band, 'windowOpacity')
p.setDuration(self.band_vis_duration)
p.finished.connect(self._on_vis_finished)
return p
示例5: slideInWidget
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setDuration [as 别名]
def slideInWidget(self, widget, direction=Automatic):
if self.indexOf(widget) == -1 or widget is self.currentWidget():
return
if self._active:
return
self._active = True
prev_widget = self.currentWidget()
next_widget = widget
if direction == self.Automatic:
if self.indexOf(prev_widget) < self.indexOf(next_widget):
direction = self.BottomToTop if self.verticalMode else self.RightToLeft
else:
direction = self.TopToBottom if self.verticalMode else self.LeftToRight
width = self.frameRect().width()
height = self.frameRect().height()
# the following is important, to ensure that the new widget has correct geometry information when sliding in the first time
next_widget.setGeometry(0, 0, width, height)
if direction in (self.TopToBottom, self.BottomToTop):
offset = QPoint(0, height if direction == self.TopToBottom else -height)
elif direction in (self.LeftToRight, self.RightToLeft):
offset = QPoint(width if direction == self.LeftToRight else -width, 0)
# re-position the next widget outside of the display area
prev_widget_position = prev_widget.pos()
next_widget_position = next_widget.pos()
next_widget.move(next_widget_position - offset)
next_widget.show()
next_widget.raise_()
prev_widget_animation = QPropertyAnimation(prev_widget, "pos")
prev_widget_animation.setDuration(self.animationDuration)
prev_widget_animation.setEasingCurve(QEasingCurve(self.animationEasingCurve))
prev_widget_animation.setStartValue(prev_widget_position)
prev_widget_animation.setEndValue(prev_widget_position + offset)
next_widget_animation = QPropertyAnimation(next_widget, "pos")
next_widget_animation.setDuration(self.animationDuration)
next_widget_animation.setEasingCurve(QEasingCurve(self.animationEasingCurve))
next_widget_animation.setStartValue(next_widget_position - offset)
next_widget_animation.setEndValue(next_widget_position)
self._animation_group.clear()
self._animation_group.addAnimation(prev_widget_animation)
self._animation_group.addAnimation(next_widget_animation)
self._animation_group.start()
示例6: CurrentSelection
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setDuration [as 别名]
class CurrentSelection(QgsRubberBand):
"""
Position marker for the current location in the viewer.
"""
class AniObject(QObject):
def __init__(self, band):
super(CurrentSelection.AniObject, self).__init__()
self.color = QColor()
@pyqtProperty(int)
def alpha(self):
return self.color.alpha()
@alpha.setter
def alpha(self, value):
self.color.setAlpha(value)
def __init__(self, canvas):
super(CurrentSelection, self).__init__(canvas)
self.outline = QgsRubberBand(canvas)
self.outline.setBrushStyle(Qt.NoBrush)
self.outline.setWidth(5)
self.outline.setIconSize(30)
self.aniobject = CurrentSelection.AniObject(self)
self.anim = QPropertyAnimation(self.aniobject, "alpha")
self.anim.setDuration(500)
self.anim.setStartValue(50)
self.anim.setEndValue(100)
self.anim.valueChanged.connect(self.value_changed)
def setOutlineColour(self, color):
self.outline.setColor(color)
def setToGeometry(self, geom, layer):
super(CurrentSelection, self).setToGeometry(geom, layer)
self.outline.setToGeometry(geom, layer)
self.anim.stop()
self.anim.start()
def reset(self, geomtype=QGis.Line):
super(CurrentSelection, self).reset(geomtype)
self.outline.reset(geomtype)
self.anim.stop()
def value_changed(self, value):
self.setColor(self.aniobject.color)
self.update()
def setColor(self, color):
self.aniobject.color = color
super(CurrentSelection, self).setColor(color)
示例7: trigger
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setDuration [as 别名]
def trigger(self, ui):
"""
Trigger this animation
"""
damage_counter = DamageCounter(damage=str(self.damage),
colour=self.colour,
parent=ui)
ui.view.scene().addItem(damage_counter)
damage_counter.setZValue(zorder_counter)
bounds = damage_counter.boundingRect()
width = bounds.width()
rand = Random()
damage_counter.setPos((self.location[0] * 32
+ 16 - (width / 2)
+ rand.randint(-16, 16)) + self.offset[0],
self.location[1] * 32 + self.offset[1])
animation = QSequentialAnimationGroup()
moving = QPropertyAnimation(damage_counter.adapter,
'y_location')
moving.setDuration(750)
moving.setStartValue(self.location[1] * 32 + self.offset[1])
moving.setEndValue(self.location[1] * 32 - 32 + self.offset[1])
curve = QEasingCurve(QEasingCurve.OutElastic)
moving.setEasingCurve(curve)
animation.addAnimation(moving)
fading = QPropertyAnimation(damage_counter.adapter,
'opacity')
fading.setDuration(750)
fading.setStartValue(1.0)
fading.setEndValue(0.0)
animation.addAnimation(fading)
def clean_up():
animation.stop()
ui.animations.remove(animation)
ui.view.items().remove(damage_counter)
ui.remove_finished_animation()
animation.finished.connect(clean_up)
ui.animations.append(animation)
animation.start()
示例8: test
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setDuration [as 别名]
class test(QDialog):
def __init__(self,parent=None):
super(test,self).__init__(parent)
self.pushbutton = MyButton('Popup Button')
# self.pushbutton.setAutoFillBackground(False)
self.pushbutton.move(0, 50)
# self._alpha = 255
# self.pushbutton.setStyle('plastique')
# self.animation = QPropertyAnimation(self.pushbutton, "geometry")
# self.animation.setDuration(1000)
# self.animation.setKeyValueAt(0, QRect(100, 100, 50, 30));
# self.animation.setKeyValueAt(0.8, QRect(150, 150, 50, 30));
# self.animation.setKeyValueAt(1, QRect(100, 100, 50, 30));
self.animation = QPropertyAnimation(self.pushbutton, "alpha")
self.animation.setDuration(1000)
# self.animation.setStartValue(20)
# self.animation.setEndValue(255)
self.animation.setKeyValueAt(0, 10)
self.animation.setKeyValueAt(0.5, 200)
self.animation.setKeyValueAt(1, 255)
self.animation.setLoopCount(5)
self.animation.start()
# print(self.pushbutton)
layout = QVBoxLayout()
layout.addWidget(self.pushbutton)
# layout.addLayout(btnlayout2)
# layout.addLayout(bottomlayout2)
self.setLayout(layout)
self.setGeometry(100, 100, 200, 200)
# menu = QtGui.QMenu()
# menu.addAction('This is Action 1', self.Action1)
# menu.addAction('This is Action 2', self.Action2)
# pushbutton.setMenu(menu)
# self.setCentralWidget(pushbutton)
def Action1(self):
print('You selected Action 1')
def Action2(self):
print('You selected Action 2')
示例9: test
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setDuration [as 别名]
def test():
# 动来动去的按钮
button = QPushButton("Button")
button.show()
# 生成一个动画, 它会修改button的geometry属性
animation = QPropertyAnimation(button, "geometry")
# 动画时间是10秒
animation.setDuration(10000)
# 开始的位置
animation.setStartValue(QRect(0, 0, 100, 30))
# 结束的位置
animation.setEndValue(QRect(250, 250, 100, 30))
# 开始吧
animation.start()
app.exec_()
示例10: groupAnimation
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setDuration [as 别名]
def groupAnimation(ws, btngroup):
# 建立一个平行的动作组
ag = QParallelAnimationGroup()
for w in ws:
tmpbtn = btngroup.button(int(w[0]))
# 对于每个按钮, 都生成一个进入的动作
a = QPropertyAnimation(tmpbtn, "alpha")
a.setDuration(200)
a.setKeyValueAt(0, 10)
# a.setKeyValueAt(0.5, 200)
a.setKeyValueAt(1, 255)
a.setLoopCount(-1)
a.setEasingCurve(QEasingCurve.OutQuad)
# a.setStartValue(QRect(-100, w.y(), w.width(), w.height()))
# a.setEndValue(w.geometry())
# 添加到组里面去
ag.addAnimation(a)
return ag
示例11: HtmlViewerWidget
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setDuration [as 别名]
class HtmlViewerWidget(QWidget):
def __init__(self, parent):
super(HtmlViewerWidget, self).__init__(parent)
self.setLayout(QGridLayout())
self.layout().setContentsMargins(0, 0, 0, 0)
self.view = QWebView()
self.view.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
self.frame = QFrame()
self.frame.setLayout(QGridLayout())
self.frame.layout().setContentsMargins(0, 0, 0, 0)
self.toolbar = QToolBar()
self.spacer = QWidget()
self.spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.copyAction = self.toolbar.addAction(QIcon(":/icons/clipboard"), "Copy Text")
self.label = QLabel()
self.closeAction = self.toolbar.addAction(QIcon(":/icons/cancel"), "Close")
self.spaceraction = self.toolbar.insertWidget(self.closeAction, self.spacer)
self.labelaction = self.toolbar.insertWidget(self.spaceraction, self.label)
self.closeAction.triggered.connect(self.close)
self.copyAction.triggered.connect(self.copy_text)
self.layout().addWidget(self.frame)
self.frame.layout().addWidget(self.toolbar)
self.frame.layout().addWidget(self.view)
self.effect = QGraphicsOpacityEffect()
self.label.setGraphicsEffect(self.effect)
self.anim = QPropertyAnimation(self.effect, "opacity")
self.anim.setDuration(2000)
self.anim.setStartValue(1.0)
self.anim.setEndValue(0.0)
self.anim.setEasingCurve(QEasingCurve.OutQuad )
def copy_text(self):
self.label.setText("Copied to clipboard")
text = self.view.page().mainFrame().toPlainText()
QApplication.clipboard().setText(text)
self.anim.stop()
self.anim.start()
def showHTML(self, template, level, **data):
html = templates.render_tample(template, **data)
self.view.setHtml(html, templates.baseurl)
示例12: LineAnimation
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setDuration [as 别名]
class LineAnimation(Animation):
def getPos(self):
return self.__pos
def setPos(self, pos):
self.__pos = pos
pos = pyqtProperty("QPointF", getPos, setPos)
def __init__(self, p1, p2, color, duration, parent = None):
super(LineAnimation, self).__init__(parent)
self.startPoint = QPointF(p1[0], p1[1])
self.endPoint = QPointF(p2[0], p2[1])
self.__pos = self.startPoint
self.color = color
self.anim = QPropertyAnimation(self, "pos", self)
self.anim.setStartValue(self.startPoint)
self.anim.setEndValue(self.endPoint)
self.anim.setDuration(duration)
self.anim.valueChanged.connect(self.updated)
self.anim.finished.connect(self.finished)
def start(self):
self.anim.start()
def stop(self):
self.anim.stop()
def paint(self, painter):
pen = QPen(Qt.black)
pen.setWidthF(2.5)
painter.setPen(pen)
line = QLineF(self.startPoint, self.pos)
painter.drawLine(line)
if self.pos != self.startPoint:
#draw arrowhead
a = line.angle()
l1 = QLineF.fromPolar(25, a - 155)
l1.translate(self.pos)
l2 = QLineF.fromPolar(25, a + 155)
l2.translate(self.pos)
painter.drawLine(l1)
painter.drawLine(l2)
示例13: _start_animation
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setDuration [as 别名]
def _start_animation(self, show=True):
if not self.USE_ANIMATIONS:
g = self.child.geometry()
self.child_state = self.STATE_ANIMATING
if show:
g.setHeight(self.preferred_size.height())
else:
g.setHeight(0)
self.child.setGeometry(g)
self.mandated_size.setHeight(g.height())
self.update()
self.child_state = self.STATE_VISIBLE if show else self.STATE_HIDDEN
return
self.update()
a = QPropertyAnimation(self.child, "geometry", self)
g = self.child.geometry()
g.setHeight(0)
a.setStartValue(g)
g.setHeight(self.preferred_size.height())
a.setEndValue(g)
a.setEasingCurve(QEasingCurve.OutQuad)
a.setDuration(self.duration)
def valueChanged(qv):
r = qv.toRect()
self.mandated_size.setHeight(r.height())
self.update()
connect(a, SIGNAL("valueChanged(QVariant)"), valueChanged)
if not show:
a.setDirection(a.Backward)
connect(a, SIGNAL("finished()"), lambda: setattr(self, "child_state", self.STATE_HIDDEN))
else:
a.setDirection(a.Forward)
connect(a, SIGNAL("finished()"), lambda: setattr(self, "child_state", self.STATE_VISIBLE))
self.child_state = self.STATE_ANIMATING
a.start(a.DeleteWhenStopped)
示例14: OutputTab
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setDuration [as 别名]
class OutputTab(QTabWidget):
def __init__(self,parent):
QTabWidget.__init__(self,parent)
self.setTabBar(MyTabBar(self))
self.setMaximumHeight(200)#260
self.anim = QPropertyAnimation(self, "geometry")
self.anim.setDuration(3000)
self.anim.setStartValue(QRect(0,0,100,0))
self.anim.setEndValue(QRect(0,0,100,200))
self.anim.setEasingCurve(QEasingCurve.InOutQuad)
if(config.hide() == 1):
#self.setFixedHeight(200)
self.timer = QTimer(self)
self.timer.timeout.connect(self.close)
#self.connect(self.tabBar(), SIGNAL("tabno"),self.pop_out)
#self.connect(self.tabBar(), SIGNAL("enter"),self.enter_show)
#self.connect(self.tabBar(), SIGNAL("leave"),self.leave_hide)
self.hide()
else:
#self.setFixedHeight(200)
self.hide()
def pop_out(self,no):
#print "Hover Over Output tab: ",no
if(no != 2):
self.setCurrentIndex(no)
def enter_show(self):
self.anim.start()
self.show()
def leave_hide(self):
self.timer.start(2000)
def close(self):
#self.setFixedHeight(30)
self.timer.stop()
示例15: Slider
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setDuration [as 别名]
class Slider(QFrame):
def __init__(self, minimap):
QFrame.__init__(self, minimap)
self._minimap = minimap
self.setStyleSheet("background: gray; border-radius: 3px;")
# Opacity
self.effect = QGraphicsOpacityEffect()
self.setGraphicsEffect(self.effect)
self.effect.setOpacity(0.2)
# Animación
self.animation = QPropertyAnimation(self.effect, "opacity")
self.animation.setDuration(150)
# Cursor
self.setCursor(Qt.OpenHandCursor)
def mouseMoveEvent(self, event):
super(Slider, self).mouseMoveEvent(event)
#FIXME: funciona algo loco
pos = self.mapToParent(event.pos())
dy = pos.y() - (self.height() / 2)
if dy < 0:
dy = 0
self.move(0, dy)
pos.setY(pos.y() - event.pos().y())
self._minimap._weditor.verticalScrollBar().setValue(pos.y())
self._minimap.verticalScrollBar().setSliderPosition(
self._minimap.verticalScrollBar().sliderPosition() + 2)
self._minimap.verticalScrollBar().setValue(pos.y() - event.pos().y())
def mousePressEvent(self, event):
super(Slider, self).mousePressEvent(event)
self.setCursor(Qt.ClosedHandCursor)
def mouseReleaseEvent(self, event):
super(Slider, self).mouseReleaseEvent(event)
self.setCursor(Qt.OpenHandCursor)