本文整理汇总了Python中PyQt4.QtCore.QPropertyAnimation.stop方法的典型用法代码示例。如果您正苦于以下问题:Python QPropertyAnimation.stop方法的具体用法?Python QPropertyAnimation.stop怎么用?Python QPropertyAnimation.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QPropertyAnimation
的用法示例。
在下文中一共展示了QPropertyAnimation.stop方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CurrentSelection
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import stop [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)
示例2: HtmlViewerWidget
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import stop [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)
示例3: LineAnimation
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import stop [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)
示例4: ExplodingAnimation
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import stop [as 别名]
class ExplodingAnimation(Animation):
def __init__(self, center, duration, parent = None):
super(ExplodingAnimation, self).__init__(parent)
self.center = center
self.__radius = 1.0
self.anim = QPropertyAnimation(self, "radius")
self.anim.setStartValue(1.0)
self.anim.setEndValue(100.0)
self.anim.setDuration(duration)
self.anim.setEasingCurve(QEasingCurve.OutExpo)
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 getRadius(self):
return self.__radius
def setRadius(self, r):
self.__radius = r
radius = pyqtProperty("qreal", getRadius, setRadius)
def paint(self, painter):
opacity = 1.0 - float(self.anim.currentTime()) / self.anim.duration()
pen = QPen(QColor(255, 0, 0, opacity * 255))
pen.setWidth(3)
painter.setPen(pen)
painter.setBrush(Qt.transparent)
rect = QRect(0, 0, self.radius * 2, self.radius * 2)
rect.moveCenter(self.center)
painter.drawEllipse(rect)
示例5: CImprovedButton
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import stop [as 别名]
class CImprovedButton(QToolButton):
def __init__(self, parent=None):
QToolButton.__init__(self, parent)
#TESTO ALTERNATIVO
#Spesso se il pulsante ha icona troppo grossa e quando per ragioni di spazio o altro non si può spostare
#o ridimensionare il pulsante stesso, la label ha posizioni assurde e schifose. Aggiungerne una "+ controllabile"
#è l'unico modo..
self.__fixed_label = QLabel("alternative label", self)
self.__fixed_label.move(0, self.geometry().height() - 35)
self.__fixed_label.resize(self.geometry().width(), self.__fixed_label.geometry().height())
self.__fixed_label.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
self.__font = QtGui.QFont("Arial", 10)
self.__fixed_label.setFont(self.__font)
self.__fixed_label.show()
#INDICATORE STILE iOS
self.__indicator = QLabel("0", self)
self.__indicator.setStyleSheet("border-image: url(':/images/backgrounds/indicator.png'); padding-right:1px; color: white;")
self.__indicator.geometry().setWidth(25)
self.__indicator.geometry().setHeight(20)
self.__indicator.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
self.__indicator.setVisible(False)
self.setIndicatorPos(QPoint(self.width() - self.__indicator.width(), 0)) #default top-right corner
#Quando il pulsante viene ridimensionato (designer o meno) devo anche sistemare la label di conseguenza
self.resizeEvent = self.__onResize
self.__indicator.resizeEvent = self.__on_indicator_Resize
self.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
self.clicked.connect(self.stopAllAnimations)
#BLINK
self.__blink_timer = QTimer(parent)
self.__blink_timer.timeout.connect(self.__on_blink_timer)
self.__blink_timer_interval = 1000
#FADING
self.__opacity_effect = QGraphicsOpacityEffect()
self.__fading_timer = QTimer(parent)
self.__fading_timer.timeout.connect(self.__on_fading_timer)
self.__FADE_TYPE = Enum("IN", "OUT")
self.__fade_time = 20
self.__opacity = 1.0
self.__opacity_fading_coefficient = 0.02
self.__selected_fade_type = self.__FADE_TYPE.IN
# ANIMAZIONI GROW
self.__animationGrow = QPropertyAnimation(self, "iconSize", self)
self.__animationGrow.setDuration(1000)
self.__animationGrow.setEasingCurve(QEasingCurve.Linear)
self.__animationGrow.finished.connect(self.__on_growed)
self.__animationShrink = QPropertyAnimation(self, "iconSize", self)
self.__animationShrink.setDuration(1000)
self.__animationShrink.setEasingCurve(QEasingCurve.Linear)
self.__animationShrink.finished.connect(self.__on_shrinked)
self.__defaultIconDimension = 60
self.__iconGrowsBy = 40
self.__growing = False
# ANIMAZIONI BOUNCE
self.__animationUp = QPropertyAnimation(self, "pos", self)
self.__animationUp.setDuration(200)
self.__animationUp.setEasingCurve(QEasingCurve.Linear)
self.__animationUp.finished.connect(self.__on_top_reached)
self.__animationBounce = QPropertyAnimation(self, "pos", self)
self.__animationBounce.setDuration(1000)
self.__animationBounce.setEasingCurve(QEasingCurve.OutBounce)
self.__animationBounce.finished.connect(self.__on_bounce_finished)
self.__bouncing = False
self.__startPos = QPoint(self.pos().x(), self.pos().y())
#PIXMAP & MASCHERA
self.__pmap = QPixmap(self.size())
self.__pmap_fname = ""
self.__show_mask_preview = False
def setDefaultIconSize(self, value):
""" Sets default icon size when growing stops.
@param value: size (both width and height)
@type value: int
"""
self.__defaultIconDimension = value
def getDefaultIconSize(self):
return self.__defaultIconDimension
defaultIconSize = QtCore.pyqtProperty("int", getDefaultIconSize, setDefaultIconSize)
def setFixetTextVisibility(self, bool):
""" Sets if fixed text is visible or not.
@param bool: visible or not
@type bool: bool
"""
self.__fixed_label.setVisible(bool)
#.........这里部分代码省略.........
示例6: CellSkin
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import stop [as 别名]
class CellSkin(Cell):
sel_brush = QBrush(QColor("cyan"))
sel_pen = QPen(QBrush(QColor("black")), 3)
posChanged = pyqtSignal()
def __init__(self, cid, data, cons=None, props=None):
Cell.__init__(self, cid, data, cons, props)
self.skin = None
self.old_brush = None
self.old_pen = None
self.loaded = False
self.initialMove = True
self.animation = QPropertyAnimation()
# Called when we can't find the attribute, probably going
# to skin
def __getattr__(self, name):
if name in self.__dict__:
return self.__dict__[name]
return self.__dict__["skin"].__getattribute__(name)
def __del__(self):
if self.skin:
del self.skin
def getChild(self, num=0):
childs = self.skin.childItems()
if self.skin and num >= 0 and \
num < len(childs):
return childs[num]
return None
def getSkin(self):
return self.skin
def add(self, space):
if not self.loaded:
if not self.skin:
self.skin = Skin()
self.skin.xChanged.connect(self.posChanged)
self.skin.yChanged.connect(self.posChanged)
self.skin.zChanged.connect(self.posChanged)
self.skin.setPen(QPen(QBrush(QColor("black")), 1))
self.skin.setBrush(QColor("tan"))
dlog.debug("adding skin for first time: " + str(self.skin))
space.scene.addItem(self.getSkin())
self.placeChildren(space)
self.updateRect()
self.skin.setZValue(2)
self.initialMove = True
else:
dlog.debug ("adding item: " + str(self.getSkin()))
space.scene.addItem(self.getSkin())
self.loaded = True
@pyqtSlot()
def updateRect(self):
if self.skin:
self.skin.setRect(self.skin.childrenBoundingRect())
def setPos(self, center):
if self.skin:
# setPos works in terms of topLeft, but center point is
# easiest on the frontend, so convert
rect = self.getSkin().sceneBoundingRect()
topLeft = QPointF(center[0] - rect.width()/2,
center[1] - rect.height()/2)
if self.initialMove:
self.skin.setPos(topLeft)
self.skin.setTargetPos(topLeft)
self.initialMove = False
else:
self.animation.stop()
while self.animation.state() != self.animation.Stopped:
pass
self.animation.setTargetObject(self.skin)
self.animation.setPropertyName("pos")
self.animation.setDuration(1000)
self.animation.setEndValue(topLeft)
self.skin.setTargetPos(topLeft)
self.animation.start()
def remove(self, scene, cached=True):
if not self.loaded:
return
scene.removeItem(self.getSkin())
self.loaded = False
if not cached:
self.skin = None
def select(self):
# subclasses can play with these, so save them
self.old_brush = self.skin.brush()
self.old_pen = self.skin.pen()
self.skin.setBrush(self.sel_brush)
self.skin.setPen(self.sel_pen)
self.skin.setZValue(8)
def deselect(self):
#.........这里部分代码省略.........
示例7: LetterItem
# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import stop [as 别名]
#.........这里部分代码省略.........
value.setY(min(max(value.y(), rect.top()), rect.bottom() -
self.LETTER_SIZE))
return value
elif change == self.ItemVisibleChange and self.isVisible() and \
not self.deleted:
self.animation = QPropertyAnimation(self, 'opacity')
self.animation.setDuration(250)
self.animation.setStartValue(0)
self.animation.setEndValue(1)
self.animation.start()
return super().itemChange(change, value)
def mousePressEvent(self, event):
''' Fired when the LetterItem is pressed '''
self.last_valid_position = self.scenePos()
self.hovers = set()
self.setZValue(1000)
super().mousePressEvent(event)
def mouseMoveEvent(self, event):
'''
Fired when the LetterItem is moved, propagates a custom letter event
to underlying RackItem and BoardItem objects
'''
super().mouseMoveEvent(event)
pos = self.scenePos() + self.LETTER_CENTER
items = set(item for item in self.scene().items(pos)
if type(item) in (RackItem, BoardItem))
for item in items:
item.letterMoveEvent(self)
for item in self.hovers:
if item not in items:
item.letterMoveOutEvent(self)
self.hovers = items
def mouseReleaseEvent(self, event):
'''
Fired when the LetterItem is released, propagates a custom letter event
to underlying RackItem and BoardItem objects
'''
self.setZValue(1)
super().mouseReleaseEvent(event)
if self.last_valid_position == self.scenePos() and not self.is_safe:
self.selected = not self.selected
if self.scene() and self.scene().views():
self.scene().views()[0].letterChanged.emit()
else:
items = self.scene().items(self.scenePos() + self.LETTER_CENTER)
for item in items:
if type(item) in (RackItem, BoardItem):
return item.letterReleaseEvent(self)
self.move(self.last_valid_position)
def undo(self):
''' Moves the LetterItem back to the last valid position '''
self.move(self.last_valid_position)
def own(self, new_owner, *args, **kwargs):
'''
Removes the Letter from a maybe existing owner and calls the new
owners addLetter routine
'''
if self.owner:
self.owner.removeLetter(self, *self.owner_args,
**self.owner_kwargs)
if new_owner:
self.owner = new_owner
self.owner_args = args
self.owner_kwargs = kwargs
self.owner.addLetter(self, *args, **kwargs)
if self.scene() and self.scene().views():
self.scene().views()[0].letterChanged.emit()
def move(self, pos):
''' A simple animation to move the letter '''
self.animation = QPropertyAnimation(self, 'pos')
self.animation.setDuration(100)
self.animation.setStartValue(self.scenePos())
self.animation.setEndValue(pos)
self.animation.start()
def center(self):
''' Get the center position of the Letter '''
return self.scenePos() + self.LETTER_CENTER
def remove(self):
self.scene().removeItem(self)
del self
def fade(self):
if self.animation:
self.animation.stop()
self.deleted = True
self.animation = QPropertyAnimation(self, 'opacity')
self.animation.setDuration(250)
self.animation.setStartValue(self.opacity())
self.animation.setEndValue(0)
self.animation.finished.connect(self.remove)
self.animation.start()