本文整理汇总了Python中PyQt4.QtGui.QGraphicsDropShadowEffect.blurRadius方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsDropShadowEffect.blurRadius方法的具体用法?Python QGraphicsDropShadowEffect.blurRadius怎么用?Python QGraphicsDropShadowEffect.blurRadius使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QGraphicsDropShadowEffect
的用法示例。
在下文中一共展示了QGraphicsDropShadowEffect.blurRadius方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FaceButtonsView
# 需要导入模块: from PyQt4.QtGui import QGraphicsDropShadowEffect [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsDropShadowEffect import blurRadius [as 别名]
class FaceButtonsView(QGraphicsView):
def __init__(self, *args):
QGraphicsView.__init__(self, *args)
self.move(170, 90)
self.btnSize = 40
self.padding = 5
self.setMaximumHeight(self.btnSize * 4)
self.setMaximumWidth(self.btnSize * 4)
self.setMinimumHeight(self.btnSize * 4)
self.setMinimumWidth(self.btnSize * 4)
self.adjustSize()
self.setStyleSheet('background-color:transparent; border-width: 0px; border: 0px;')
self.scene = QGraphicsScene(self)
self.psButtons = QPixmap(os.getcwd() + '/../icons/PS3_Buttons.png')
self.triangle = self.psButtons.copy(0, 0, 220, 225)
self.triangle = self.triangle.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.square = self.psButtons.copy(220, 0, 220, 225)
self.square = self.square.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.circle = self.psButtons.copy(440, 0, 220, 225)
self.circle = self.circle.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.cross = self.psButtons.copy(660, 0, 220, 225)
self.cross = self.cross.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.triangleItem = QGraphicsPixmapItem(self.triangle)
self.triangleItem.setOffset(QPointF(self.btnSize + self.padding, 0))
self.scene.addItem(self.triangleItem)
self.squareItem = QGraphicsPixmapItem(self.square)
self.squareItem.setOffset(QPointF(0, self.btnSize + self.padding))
self.scene.addItem(self.squareItem)
self.circleItem = QGraphicsPixmapItem(self.circle)
self.circleItem.setOffset(QPointF(self.btnSize * 2 + self.padding * 2, self.btnSize + self.padding))
self.scene.addItem(self.circleItem)
self.crossItem = QGraphicsPixmapItem(self.cross)
self.crossItem.setOffset(QPointF(self.btnSize + self.padding, self.btnSize * 2 + self.padding * 2))
self.scene.addItem(self.crossItem)
self.effect = QGraphicsDropShadowEffect()
self.effect.setOffset(0, 0)
self.effect.setBlurRadius(20)
self.effect.setColor(Qt.green)
self.triangleItem.setGraphicsEffect(self.effect)
self.setScene(self.scene)
self.tl2 = QTimeLine(10000)
self.tl2.setFrameRange(0, 10000)
self.t = QGraphicsItemAnimation()
self.t.setItem(self.triangleItem)
self.t.setTimeLine(self.tl2)
self.tl2.connect(self.tl2, SIGNAL('frameChanged(int)'), self.updateEffect)
self.effectd = 3
self.tl2.start()
def updateEffect(self):
if self.effect.blurRadius() > 50:
self.effectd = -3
elif self.effect.blurRadius() < 5:
self.effectd = 3
self.effect.setBlurRadius(self.effect.blurRadius() + self.effectd)
示例2: DpadView
# 需要导入模块: from PyQt4.QtGui import QGraphicsDropShadowEffect [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsDropShadowEffect import blurRadius [as 别名]
class DpadView(QGraphicsView):
def __init__(self, *args):
QGraphicsView.__init__(self, *args)
self.move(2, 90)
self.btnSize = 75
self.padding = -35
self.setMaximumHeight(self.btnSize * 2 + 20)
self.setMaximumWidth(self.btnSize * 2 + 20)
self.setMinimumHeight(self.btnSize * 2 + 20)
self.setMinimumWidth(self.btnSize * 2 + 20)
self.adjustSize()
self.setStyleSheet('background-color:transparent; border-width: 0px; border: 0px;')
self.scene = QGraphicsScene(self)
self.left = QPixmap(os.getcwd() + '/../icons/left.png')
self.left = self.left.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.right = QPixmap(os.getcwd() + '/../icons/right.png')
self.right = self.right.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.up = QPixmap(os.getcwd() + '/../icons/up.png')
self.up = self.up.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.down = QPixmap(os.getcwd() + '/../icons/down.png')
self.down = self.down.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.leftItem = QGraphicsPixmapItem(self.left)
self.leftItem.setOffset(QPointF(0, self.btnSize + self.padding))
self.scene.addItem(self.leftItem)
self.rightItem = QGraphicsPixmapItem(self.right)
self.rightItem.setOffset(QPointF(self.btnSize * 2 + self.padding * 2, self.btnSize + self.padding))
self.scene.addItem(self.rightItem)
self.upItem = QGraphicsPixmapItem(self.up)
self.upItem.setOffset(QPointF(self.btnSize + self.padding, 0))
self.scene.addItem(self.upItem)
self.downItem = QGraphicsPixmapItem(self.down)
self.downItem.setOffset(QPointF(self.btnSize + self.padding, self.btnSize * 2 + self.padding * 2))
self.scene.addItem(self.downItem)
self.effect = QGraphicsDropShadowEffect()
self.effect.setOffset(0, 0)
self.effect.setBlurRadius(20)
self.effect.setColor(Qt.green)
self.downItem.setGraphicsEffect(self.effect)
self.setScene(self.scene)
self.tl2 = QTimeLine(10000)
self.tl2.setFrameRange(0, 10000)
self.t = QGraphicsItemAnimation()
self.t.setItem(self.downItem)
self.t.setTimeLine(self.tl2)
self.tl2.connect(self.tl2, SIGNAL('frameChanged(int)'), self.updateEffect)
self.effectd = 3
self.tl2.start()
def updateEffect(self):
if self.effect.blurRadius() > 50:
self.effectd = -3
elif self.effect.blurRadius() < 5:
self.effectd = 3
self.effect.setBlurRadius(self.effect.blurRadius() + self.effectd)
示例3: NodeBodyItem
# 需要导入模块: from PyQt4.QtGui import QGraphicsDropShadowEffect [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsDropShadowEffect import blurRadius [as 别名]
class NodeBodyItem(GraphicsPathObject):
"""
The central part (body) of the `NodeItem`.
"""
def __init__(self, parent=None):
GraphicsPathObject.__init__(self, parent)
assert(isinstance(parent, NodeItem))
self.__processingState = 0
self.__progress = -1
self.__animationEnabled = False
self.__isSelected = False
self.__hasFocus = False
self.__hover = False
self.__shapeRect = QRectF(-10, -10, 20, 20)
self.setAcceptHoverEvents(True)
self.setFlag(QGraphicsItem.ItemSendsScenePositionChanges, True)
self.setFlag(QGraphicsItem.ItemSendsGeometryChanges, True)
self.setPen(QPen(Qt.NoPen))
self.setPalette(default_palette())
self.shadow = QGraphicsDropShadowEffect(
blurRadius=3,
color=QColor(SHADOW_COLOR),
offset=QPointF(0, 0),
)
self.setGraphicsEffect(self.shadow)
self.shadow.setEnabled(True)
self.__blurAnimation = QPropertyAnimation(self.shadow, "blurRadius",
self)
self.__blurAnimation.setDuration(100)
self.__blurAnimation.finished.connect(self.__on_finished)
self.__pingAnimation = QPropertyAnimation(self, "scale", self)
self.__pingAnimation.setDuration(250)
self.__pingAnimation.setKeyValues([(0.0, 1.0), (0.5, 1.1), (1.0, 1.0)])
# TODO: The body item should allow the setting of arbitrary painter
# paths (for instance rounded rect, ...)
def setShapeRect(self, rect):
"""
Set the item's shape `rect`. The item should be confined within
this rect.
"""
path = QPainterPath()
path.addEllipse(rect)
self.setPath(path)
self.__shapeRect = rect
def setPalette(self, palette):
"""
Set the body color palette (:class:`QPalette`).
"""
self.palette = palette
self.__updateBrush()
def setAnimationEnabled(self, enabled):
"""
Set the node animation enabled.
"""
if self.__animationEnabled != enabled:
self.__animationEnabled = enabled
def setProcessingState(self, state):
"""
Set the processing state of the node.
"""
if self.__processingState != state:
self.__processingState = state
if not state and self.__animationEnabled:
self.ping()
def setProgress(self, progress):
"""
Set the progress indicator state of the node. `progress` should
be a number between 0 and 100.
"""
self.__progress = progress
self.update()
def ping(self):
"""
Trigger a 'ping' animation.
"""
animation_restart(self.__pingAnimation)
def hoverEnterEvent(self, event):
self.__hover = True
self.__updateShadowState()
return GraphicsPathObject.hoverEnterEvent(self, event)
def hoverLeaveEvent(self, event):
#.........这里部分代码省略.........
示例4: SixAxisView
# 需要导入模块: from PyQt4.QtGui import QGraphicsDropShadowEffect [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsDropShadowEffect import blurRadius [as 别名]
class SixAxisView(QGraphicsView):
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()
def updateEffect(self):
if self.effect.blurRadius() > 50:
self.effectd = -3
elif self.effect.blurRadius() < 5:
self.effectd = 3
self.effect.setBlurRadius(self.effect.blurRadius() + self.effectd)
def update(self, *args, **kwargs):
return QGraphicsView.update(self, *args, **kwargs)
def moveJoysticks(self, x, y, a, z, l3, r3):
x2 = x * self.innerRange / self.inputRange - self.innerRange / 2
y2 = y * self.innerRange / self.inputRange - self.innerRange / 2
a2 = a * self.innerRange / self.inputRange - self.innerRange / 2
z2 = z * self.innerRange / self.inputRange - self.innerRange / 2
if -self.thresh <= x2 <= self.thresh:
x2 = 0
if -self.thresh <= y2 <= self.thresh:
y2 = 0
if -self.thresh <= a2 <= self.thresh:
a2 = 0
if -self.thresh <= z2 <= self.thresh:
z2 = 0
self.tl = QTimeLine(10)
self.tl.setFrameRange(0, 10)
self.a = QGraphicsItemAnimation()
self.a.setItem(self.innerCircle1)
self.a.setTimeLine(self.tl)
self.a.setPosAt(0, QPointF(self.currentX, self.currentY))
self.a.setTranslationAt(1, x2, y2)
if l3:
self.innerCircle1.setPen(QPen(QColor(Qt.white), 1, Qt.SolidLine))
self.innerCircle1.setBrush(QColor(200, 225, 3))
else:
self.innerCircle1.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.innerCircle1.setBrush(Qt.lightGray)
if r3:
#.........这里部分代码省略.........