diff options
Diffstat (limited to 'examples/widgets/graphicsview/collidingmice/collidingmice.py')
-rw-r--r-- | examples/widgets/graphicsview/collidingmice/collidingmice.py | 60 |
1 files changed, 10 insertions, 50 deletions
diff --git a/examples/widgets/graphicsview/collidingmice/collidingmice.py b/examples/widgets/graphicsview/collidingmice/collidingmice.py index 78fbe8041..fb24db3ab 100644 --- a/examples/widgets/graphicsview/collidingmice/collidingmice.py +++ b/examples/widgets/graphicsview/collidingmice/collidingmice.py @@ -1,56 +1,15 @@ - -############################################################################# -## -## Copyright (C) 2013 Riverbank Computing Limited. -## Copyright (C) 2021 The Qt Company Ltd. -## Contact: http://www.qt.io/licensing/ -## -## This file is part of the Qt for Python examples of the Qt Toolkit. -## -## $QT_BEGIN_LICENSE:BSD$ -## You may use this file under the terms of the BSD license as follows: -## -## "Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## * Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in -## the documentation and/or other materials provided with the -## distribution. -## * Neither the name of The Qt Company Ltd nor the names of its -## contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2013 Riverbank Computing Limited. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import math import sys -from PySide6.QtCore import (QLineF, QPointF, QRandomGenerator, QRectF, QTimer, - Qt) -from PySide6.QtGui import (QBrush, QColor, QPainter, QPainterPath, QPixmap, - QPolygonF, QTransform) -from PySide6.QtWidgets import (QApplication, QGraphicsItem, QGraphicsScene, - QGraphicsView) +from PySide6.QtCore import (QLineF, QPointF, QRandomGenerator, QRectF, QTimer, Qt) +from PySide6.QtGui import (QBrush, QColor, QPainter, QPainterPath, QPixmap, QPolygonF, QTransform) +from PySide6.QtWidgets import (QApplication, QGraphicsItem, QGraphicsScene, QGraphicsView) -import mice_rc +import mice_rc # noqa: F401 def random(boundary): @@ -64,7 +23,7 @@ class Mouse(QGraphicsItem): # Create the bounding rectangle once. adjust = 0.5 BOUNDING_RECT = QRectF(-20 - adjust, -22 - adjust, 40 + adjust, - 83 + adjust) + 83 + adjust) def __init__(self): super().__init__() @@ -141,7 +100,8 @@ class Mouse(QGraphicsItem): if angle_to_center < Mouse.PI and angle_to_center > Mouse.PI / 4: # Rotate left. self.angle += [-0.25, 0.25][self.angle < -Mouse.PI / 2] - elif angle_to_center >= Mouse.PI and angle_to_center < (Mouse.PI + Mouse.PI / 2 + Mouse.PI / 4): + elif (angle_to_center >= Mouse.PI + and angle_to_center < (Mouse.PI + Mouse.PI / 2 + Mouse.PI / 4)): # Rotate right. self.angle += [-0.25, 0.25][self.angle < Mouse.PI / 2] elif math.sin(self.angle) < 0: |