当前位置: 首页>>代码示例>>Python>>正文


Python QPropertyAnimation.setEndValue方法代码示例

本文整理汇总了Python中PyQt5.QtCore.QPropertyAnimation.setEndValue方法的典型用法代码示例。如果您正苦于以下问题:Python QPropertyAnimation.setEndValue方法的具体用法?Python QPropertyAnimation.setEndValue怎么用?Python QPropertyAnimation.setEndValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtCore.QPropertyAnimation的用法示例。


在下文中一共展示了QPropertyAnimation.setEndValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Tab

# 需要导入模块: from PyQt5.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt5.QtCore.QPropertyAnimation import setEndValue [as 别名]
class Tab(QObject):

    def __init__(self, parent):
        QObject.__init__(self, parent)
        self._toolbar = parent
        self.icon = None
        self.text = ""
        self.has_menu = False
        self.enabled = True
        self._fader = 0
        self._animator = QPropertyAnimation(self)
        self._animator.setPropertyName(b"fader")
        self._animator.setTargetObject(self)

    def fade_in(self):
        self._animator.stop()
        self._animator.setDuration(80)
        self._animator.setEndValue(1)
        self._animator.start()

    def fade_out(self):
        self._animator.stop()
        self._animator.setDuration(160)
        self._animator.setEndValue(0)
        self._animator.start()

    def _set_fader(self, value):
        self._fader = value
        self._toolbar.update()

    def _get_fader(self):
        return self._fader

    fader = pyqtProperty(float, fget=_get_fader, fset=_set_fader)
开发者ID:ninja-ide,项目名称:ninja-ide,代码行数:36,代码来源:ui_tools.py

示例2: MoveSymbol

# 需要导入模块: from PyQt5.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt5.QtCore.QPropertyAnimation import setEndValue [as 别名]
class MoveSymbol(QUndoCommand):
    ''' Undo/Redo command for moving symbols '''
    def __init__(self, symbol_id, old_pos, new_pos, animate=False):
        super(MoveSymbol, self).__init__()
        self.setText('Move symbol')
        self.symbol = symbol_id
        self.old_pos = old_pos
        self.new_pos = new_pos
        if animate:
            self.animation = QPropertyAnimation(self.symbol, "position")
            self.animation.setDuration(500)
            self.animation.setStartValue(self.old_pos)
            self.animation.setEndValue(self.new_pos)
            self.animation.setEasingCurve(QEasingCurve.OutCirc)

    def undo(self):
        ''' Undo a symbol move '''
        self.symbol.position = self.old_pos
        try:
            self.symbol.decisionParent.updateConnectionPointPosition()
        except AttributeError:
            pass

    def redo(self):
        ''' Apply a symbol move '''
        try:
            self.animation.start()
        except AttributeError:
            self.symbol.position = self.new_pos
        try:
            self.symbol.decisionParent.updateConnectionPointPosition()
        except AttributeError:
            pass
开发者ID:examon,项目名称:opengeode,代码行数:35,代码来源:undoCommands.py

示例3: createPositionAnimation

# 需要导入模块: from PyQt5.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt5.QtCore.QPropertyAnimation import setEndValue [as 别名]
 def createPositionAnimation(self, item, duration):
     ani = QPropertyAnimation(item, b'pos', self)
     ani.setDuration(duration)
     ani.setStartValue(item.pos())
     width = self.squareWidth * 7
     ani.setEndValue(QPointF(width - item.x(),
                             width - item.y()))
     return ani
开发者ID:thesmartwon,项目名称:OpenChess-Python,代码行数:10,代码来源:board.py

示例4: createAnimation

# 需要导入模块: from PyQt5.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt5.QtCore.QPropertyAnimation import setEndValue [as 别名]
    def createAnimation(self, target, index):
        '''创建动画'''
        # 暂停动画一
        PauseAnimation1 = QPauseAnimation(target)
        PauseAnimation1.setDuration(150 * index)

        # 并行动画组一
        # #透明度动画一
        OpacityAnimation1 = QPropertyAnimation(target, b"opacity")
        OpacityAnimation1.setDuration(400)
        OpacityAnimation1.setStartValue(0)
        OpacityAnimation1.setEndValue(1)
        # #移动动画一
        MoveAnimation1 = _MoveAnimation(target, self.parent, self.easing)
        MoveAnimation1.setMoveType(_MoveAnimation.MOVE1)
        MoveAnimation1.setDuration(400)
        MoveAnimation1.setStartValue(QPoint(0, 0))
        MoveAnimation1.setEndValue(QPoint(self.parent.width() / 4.0, 0))
        # 添加到并行动画里面
        ParallelAnimation1 = QParallelAnimationGroup()
        ParallelAnimation1.addAnimation(OpacityAnimation1)
        ParallelAnimation1.addAnimation(MoveAnimation1)

        # 移动动画二
        MoveAnimation2 = _MoveAnimation(target, self.parent, self.easing)
        MoveAnimation2.setMoveType(_MoveAnimation.MOVE2)
        MoveAnimation2.setDuration(2000)
        MoveAnimation2.setEndValue(QPoint((self.parent.width() / 4.0) * 3.0, 0))

        # 并行动画组二
        # #透明度动画二
        OpacityAnimation2 = QPropertyAnimation(target, b"opacity")
        OpacityAnimation2.setDuration(400)
        OpacityAnimation2.setStartValue(1)
        OpacityAnimation2.setEndValue(0)
        # #移动动画三
        MoveAnimation3 = _MoveAnimation(target, self.parent, self.easing)
        MoveAnimation3.setMoveType(_MoveAnimation.MOVE3)
        MoveAnimation3.setDuration(400)
        MoveAnimation3.setEndValue(QPoint(self.parent.width(), 0))
        # 添加到并行动画里面
        ParallelAnimation2 = QParallelAnimationGroup()
        ParallelAnimation2.addAnimation(OpacityAnimation2)
        ParallelAnimation2.addAnimation(MoveAnimation3)

        # 暂停动画二
        PauseAnimation2 = QPauseAnimation(target)
        PauseAnimation2.setDuration(150 * (5 - index - 1))

        # 串行动画组
        self.setLoopCount(-1)    # 无限循环
        self.addAnimation(PauseAnimation1)
        self.addAnimation(ParallelAnimation1)
        self.addAnimation(MoveAnimation2)
        self.addAnimation(ParallelAnimation2)
        self.addAnimation(PauseAnimation2)
开发者ID:GrandHsu,项目名称:PyQtUiLibrary,代码行数:58,代码来源:MpbAnimation.py

示例5: __init__

# 需要导入模块: from PyQt5.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt5.QtCore.QPropertyAnimation import setEndValue [as 别名]
    def __init__(self):
        super(Robot, self).__init__()

        self.setFlag(self.ItemHasNoContents)

        self.torsoItem = RobotTorso(self)
        self.headItem = RobotHead(self.torsoItem)
        self.upperLeftArmItem = RobotLimb(self.torsoItem)
        self.lowerLeftArmItem = RobotLimb(self.upperLeftArmItem)
        self.upperRightArmItem = RobotLimb(self.torsoItem)
        self.lowerRightArmItem = RobotLimb(self.upperRightArmItem)
        self.upperRightLegItem = RobotLimb(self.torsoItem)
        self.lowerRightLegItem = RobotLimb(self.upperRightLegItem)
        self.upperLeftLegItem = RobotLimb(self.torsoItem)
        self.lowerLeftLegItem = RobotLimb(self.upperLeftLegItem)

        settings = (
            #    Item                       Position        Rotation  Scale
            #                                x     y    start    end
            (self.headItem, 0, -18, 20, -20, 1.1),
            (self.upperLeftArmItem, -15, -10, 190, 180, 0),
            (self.lowerLeftArmItem, 30, 0, 50, 10, 0),
            (self.upperRightArmItem, 15, -10, 300, 310, 0),
            (self.lowerRightArmItem, 30, 0, 0, -70, 0),
            (self.upperRightLegItem, 10, 32, 40, 120, 0),
            (self.lowerRightLegItem, 30, 0, 10, 50, 0),
            (self.upperLeftLegItem, -10, 32, 150, 80, 0),
            (self.lowerLeftLegItem, 30, 0, 70, 10, 0),
            (self.torsoItem, 0, 0, 5, -20, 0),
        )

        animation = QParallelAnimationGroup(self)
        for item, pos_x, pos_y, start_rot, end_rot, scale in settings:
            item.setPos(pos_x, pos_y)

            rot_animation = QPropertyAnimation(item, b"rotation")
            rot_animation.setStartValue(start_rot)
            rot_animation.setEndValue(end_rot)
            rot_animation.setEasingCurve(QEasingCurve.SineCurve)
            rot_animation.setDuration(2000)
            animation.addAnimation(rot_animation)

            if scale > 0:
                scale_animation = QPropertyAnimation(item, b"scale")
                scale_animation.setEndValue(scale)
                scale_animation.setEasingCurve(QEasingCurve.SineCurve)
                scale_animation.setDuration(2000)
                animation.addAnimation(scale_animation)

        animation.setLoopCount(-1)
        animation.start()
开发者ID:death-finger,项目名称:Scripts,代码行数:53,代码来源:dragdroprobot.py

示例6: CircleObstruction

# 需要导入模块: from PyQt5.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt5.QtCore.QPropertyAnimation import setEndValue [as 别名]
class CircleObstruction(QColorThemedGraphicsObject):
    """
    Useful for notifications, I...guess?
    """
    def get_thickness(self):
        return self._thickness
    def set_thickness(self,c):
        self._thickness = c
        self.update()
    thickness = pyqtProperty(float, get_thickness, set_thickness)
    def __init__(self, sz, thickness, parent=None):
        super(CircleObstruction, self).__init__(parent)
        self._sz = sz
        self._thickness = thickness
        self._color = Qt.blue
    def boundingRect(self):
        return QRectF(-self._thickness,
                      -self._thickness,
                      self._sz + 2*self._thickness,
                      self._sz + 2*self._thickness)

    def paint(self, painter, option, widget):
        # painter.setPen(QPen(self._color,
        #                     self._thickness))
        painter.setBrush(self._color)
        painter.setPen(Qt.NoPen)
        painter.drawEllipse(QRectF(
            self._sz/2.0 - self._thickness,
            self._sz/2.0 - self._thickness,
            2*self._thickness,
            2*self._thickness,
        ))
    def show_anim(self):
        self.anim = QPropertyAnimation(self, "thickness")
        self.anim.setDuration(2000)
        self.anim.setStartValue(self.get_thickness())
        self.anim.setEndValue(50.0)
        self.anim.setEasingCurve(QEasingCurve.OutElastic)
        self.anim.start()
    def hide_anim(self):
        self.anim = QPropertyAnimation(self, "thickness")
        self.anim.setDuration(500)
        self.anim.setStartValue(self.get_thickness())
        self.anim.setEndValue(0.0)
        self.anim.setEasingCurve(QEasingCurve.InBack)
        self.anim.start()
开发者ID:gcr,项目名称:pocketwatch,代码行数:48,代码来源:PomodoroClockView.py

示例7: NotifyWidget

# 需要导入模块: from PyQt5.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt5.QtCore.QPropertyAnimation import setEndValue [as 别名]
class NotifyWidget(QWidget):
    def __init__(self):
        super().__init__()

        self.layout = QVBoxLayout(self)

        self.sub_widget = _NotifySubWidget(self)
        self.layout.addWidget(self.sub_widget)
        self.layout.setContentsMargins(0, 0, 0, 0)

        self._exit_shortcut = QShortcut(QKeySequence(Qt.Key_Escape), self)
        self._exit_shortcut.activated.connect(self.close)

        self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Tool)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setAttribute(Qt.WA_MacAlwaysShowToolWindow)

        self.resize(width, height)
        self.move(QApplication.desktop().width() - self.width() - 20, 40)
        self.setLayout(self.layout)

        self._animation = QPropertyAnimation(self, b'windowOpacity')
        self._animation.setStartValue(0.8)
        self._animation.setKeyValueAt(0.4, 1)
        self._animation.setEndValue(0)
        self._animation.setDuration(5000)
        self._animation.finished.connect(self.close)

    def show(self):
        super().show()
        self._animation.start()

    def show_message(self, title, content, pixmap=None):
        if not self.isVisible():
            self.show()
        self._animation.stop()
        self._animation.setCurrentTime(0)
        self._animation.start()
        self.sub_widget.set_title(title)
        self.sub_widget.set_content(content)
        pixmap = pixmap if pixmap else QPixmap(WINDOW_ICON)
        self.sub_widget.set_pixmap(pixmap)

    def enterEvent(self, event):
        self._animation.setCurrentTime(0)
开发者ID:ykelvis,项目名称:FeelUOwn,代码行数:47,代码来源:notify.py

示例8: animate

# 需要导入模块: from PyQt5.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt5.QtCore.QPropertyAnimation import setEndValue [as 别名]
    def animate(self, item, property_name, duration, start_value, end_value):
        """Summary

        Args:
            item (TYPE): Description
            property_name (TYPE): Description
            duration (TYPE): Description
            start_value (TYPE): Description
            end_value (TYPE): Description
        """
        if item is not None:
            b_name = property_name.encode('ascii')
            anim = QPropertyAnimation(item.adapter, b_name)
            anim.setDuration(duration)
            anim.setStartValue(start_value)
            anim.setEndValue(end_value)
            anim.start()
            item.adapter.saveRef(property_name, anim)
开发者ID:cadnano,项目名称:cadnano2.5,代码行数:20,代码来源:gridextras.py

示例9: animate

# 需要导入模块: from PyQt5.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt5.QtCore.QPropertyAnimation import setEndValue [as 别名]
 def animate(self, item: QGraphicsItem,
                 property_name: str, duration: int,
                 start_value, end_value):
     """
     Args:
         item: Description
         property_name: Description
         duration: Description
         start_value (QVariant): Description
         end_value (QVariant): Description
     """
     b_name = property_name.encode('ascii')
     anim = item.adapter.getRef(property_name)
     if anim is None:
         anim = QPropertyAnimation(item.adapter, b_name)
         item.adapter.saveRef(property_name, anim)
     anim.setDuration(duration)
     anim.setStartValue(start_value)
     anim.setEndValue(end_value)
     anim.start()
开发者ID:cadnano,项目名称:cadnano2.5,代码行数:22,代码来源:pathextras.py

示例10: ChannelListItem

# 需要导入模块: from PyQt5.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt5.QtCore.QPropertyAnimation import setEndValue [as 别名]
class ChannelListItem(QWidget):
    """
    This class is responsible for managing the item in the list of channels.
    The list item supports a fade-in effect, which can be enabled with the should_fade parameter in the constructor.
    """

    def __init__(self, parent, channel, fade_delay=0, should_fade=False):
        super(QWidget, self).__init__(parent)

        uic.loadUi('qt_resources/channel_list_item.ui', self)

        self.channel_name.setText(channel["name"])
        self.channel_description_label.setText("Active 6 days ago • %d items" % channel["torrents"])
        self.channel_num_subs_label.setText(str(channel["votes"]))
        if channel["sub"]:
            self.channel_subscribe_button.setText("✓ subscribed")
        else:
            self.channel_subscribe_button.setText("subscribe")

        if should_fade:
            self.opacity_effect = QGraphicsOpacityEffect(self)
            self.opacity_effect.setOpacity(0)
            self.setGraphicsEffect(self.opacity_effect)

            self.timer = QTimer()
            self.timer.setInterval(fade_delay)
            self.timer.timeout.connect(self.fadeIn)
            self.timer.start()

    def fadeIn(self):
        self.anim = QPropertyAnimation(self.opacity_effect, 'opacity')
        self.anim.setDuration(800)
        self.anim.setStartValue(0)
        self.anim.setEndValue(1)
        self.anim.start()
        self.timer.stop()
开发者ID:devos50,项目名称:TriblerGUI,代码行数:38,代码来源:channel_list_item.py

示例11: CoffeeFundWindow

# 需要导入模块: from PyQt5.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt5.QtCore.QPropertyAnimation import setEndValue [as 别名]
class CoffeeFundWindow(QWidget):
    signal_back = pyqtSignal()
    signal_coffee = pyqtSignal()
    signal_account = pyqtSignal()

    def __init__(self, parent=None):
        super().__init__()

        self.cards = {}  # type: Dict[GuiCards, QWidget]
        """
            Python's GC will clean up QPropertyAnimations as soon as it leaves the button handler,
             therefore they will appear not to work. Use members to store the animations.
            see http://stackoverflow.com/a/6953965
        """
        self.slide_in_animation = None
        self.slide_out_animation = None
        self.animation_group = None
        self.setObjectName("coffeeFundWindow")

        """
            Store the position and size of visible/hidden cards for the animation sequences
        """
        self.hidden_geometry = None
        self.visible_geometry = None

        layout = QStackedLayout()
        layout.setStackingMode(QStackedLayout.StackAll)

        card_remove = RemoveCard()
        self.cards[GuiCards.RemoveCard] = card_remove
        layout.addWidget(card_remove)

        card_choose_action = ChooseActionCard()
        self.cards[GuiCards.ChooseAction] = card_choose_action
        layout.addWidget(card_choose_action)

        card_account = AccountCard()
        self.cards[GuiCards.AccountInfo] = card_account
        layout.addWidget(card_account)

        # keep this as last initialized card, the last card will be shown on startup!
        card_start = StartCard()
        self.cards[GuiCards.Start] = card_start
        layout.addWidget(card_start)

        self.setLayout(layout)
        self.setWindowTitle("Kaffeekasse")

        layout.setCurrentWidget(card_start)
        self.active_card = None

        card_choose_action.button_account.clicked.connect(self.signal_account)
        card_choose_action.button_coffee.clicked.connect(self.signal_coffee)
        card_account.button_back.clicked.connect(self.signal_back)

    def set_card_hidden(self, card: QWidget):
        card.setGeometry(self.hidden_geometry)

    def show_start(self):
        self.show_card(GuiCards.Start)

    def show_account(self, name, value):
        self.cards[GuiCards.AccountInfo].set_user_name(name)
        self.cards[GuiCards.AccountInfo].set_balance(value)
        self.show_card(GuiCards.AccountInfo)

    def show_choose_action(self, name: str):
        self.cards[GuiCards.ChooseAction].set_user_name(name)
        self.show_card(GuiCards.ChooseAction)

    def show_remove(self):
        self.show_card(GuiCards.RemoveCard)

    def show_card(self, card_id: GuiCards):
        if self.active_card is None:
            self.active_card = self.cards[GuiCards.Start]

        if self.active_card == self.cards[card_id]:
            return

        if self.visible_geometry is None or self.hidden_geometry is None:
            self.visible_geometry = self.active_card.geometry()  # type: QRect
            self.hidden_geometry = QRect(self.visible_geometry.x(), self.visible_geometry.height() * 1.5,
                                         self.visible_geometry.width(), self.visible_geometry.height())
        for key in self.cards.keys():
            if key != self.active_card:
                self.set_card_hidden(self.cards[key])

        card_to_show = self.cards[card_id]
        self.start_card_switch(card_to_show)
        self.active_card = self.cards[card_id]
        self.layout().setCurrentWidget(self.active_card)

    def start_card_switch(self, card_to_show):
        self.slide_out_animation = QPropertyAnimation(self.active_card, "geometry")
        self.slide_out_animation.setDuration(ANIMATION_DURATION)
        self.slide_out_animation.setEasingCurve(QEasingCurve.OutCubic)
        self.slide_out_animation.setStartValue(self.visible_geometry)
        self.slide_out_animation.setEndValue(self.hidden_geometry)
        self.set_card_hidden(card_to_show)
#.........这里部分代码省略.........
开发者ID:CCTB-UW,项目名称:kaffeekasse,代码行数:103,代码来源:qtguicontroller.py

示例12: FancyButton

# 需要导入模块: from PyQt5.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt5.QtCore.QPropertyAnimation import setEndValue [as 别名]
class FancyButton(QToolButton):

    def __init__(self, text="", parent=None):
        super().__init__(parent)
        self.setAttribute(Qt.WA_Hover, True)
        self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        if text:
            self.setText(text)
        self._fader = 0

    def _set_fader(self, value):
        self._fader = value
        self.update()

    def _get_fader(self):
        return self._fader

    fader = pyqtProperty(float, fget=_get_fader, fset=_set_fader)

    def event(self, event):
        if event.type() == QEvent.Enter:
            self.anim = QPropertyAnimation(self, b"fader")
            self.anim.setDuration(150)
            self.anim.setEndValue(1.0)
            self.anim.start(QPropertyAnimation.DeleteWhenStopped)
        elif event.type() == QEvent.Leave:
            self.anim = QPropertyAnimation(self, b"fader")
            self.anim.setDuration(124)
            self.anim.setEndValue(0.0)
            self.anim.start(QPropertyAnimation.DeleteWhenStopped)
        else:
            return QToolButton.event(self, event)
        return False

    def paintEvent(self, event):
        painter = QPainter(self)
        if self.isEnabled() and not self.isDown() and not self.isChecked():
            painter.save()
            hover_color = QColor("#424242")
            faded_hover_color = QColor(hover_color)
            faded_hover_color.setAlpha(int(self._fader * hover_color.alpha()))
            painter.fillRect(event.rect(), faded_hover_color)
            painter.restore()
        elif self.isDown() or self.isChecked():
            painter.save()
            selected_color = QColor("#090909")
            painter.fillRect(event.rect(), selected_color)
            painter.restore()
        # fm = QFontMetrics(painter.font())
        # rect = QRect(-3, 2, self.rect().width(), fm.height())
        rect = event.rect()
        icon_rect = QRect(0, 0, 22, 22)
        self.icon().paint(painter, icon_rect, Qt.AlignVCenter)
        painter.drawText(
            rect.adjusted(0, 0, -3, 0),
            Qt.AlignRight | Qt.AlignVCenter, self.text())

    def sizeHint(self):
        self.ensurePolished()
        s = self.fontMetrics().size(Qt.TextSingleLine, self.text())
        s.setWidth(s.width() + 25)
        return s.expandedTo(QApplication.globalStrut())
开发者ID:ninja-ide,项目名称:ninja-ide,代码行数:64,代码来源:ui_tools.py

示例13: Preferences

# 需要导入模块: from PyQt5.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt5.QtCore.QPropertyAnimation import setEndValue [as 别名]

#.........这里部分代码省略.........
        right_container.addWidget(editor_group)
        right_container.addWidget(font_group)
        right_container.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding,
                                            QSizePolicy.Expanding))

        # Add widgets
        grid.addLayout(left_container, 0, 0)
        grid.addLayout(right_container, 0, 1)
        main_box.addLayout(grid)

        # Button close and reset
        hbox = QHBoxLayout()
        hbox.setSpacing(20)
        hbox.addItem(QSpacerItem(1, 0, QSizePolicy.Expanding))
        btn_cancel = QPushButton(self.tr("Back"))
        hbox.addWidget(btn_cancel)
        btn_reset = QPushButton(self.tr("Reset Configurations"))
        hbox.addWidget(btn_reset)
        main_box.addLayout(hbox)

        # Overlay
        self.overlay = overlay_widget.OverlayWidget(self)
        self.overlay.hide()

        # Effect and animations
        self.effect = QGraphicsOpacityEffect()
        self.setGraphicsEffect(self.effect)
        duration, x = 180, 150  # Animation duration
        # Animation start
        # Opacity animation
        self.opacity_animation_s = QPropertyAnimation(self.effect, b"opacity")
        self.opacity_animation_s.setDuration(duration)
        self.opacity_animation_s.setStartValue(0.0)
        self.opacity_animation_s.setEndValue(1.0)
        # X animation
        self.x_animation_s = QPropertyAnimation(self, b"geometry")
        self.x_animation_s.setDuration(duration)
        self.x_animation_s.setStartValue(QRect(x, 0, parent.width(),
                                               parent.height()))
        self.x_animation_s.setEndValue(QRect(0, 0, parent.width(),
                                             parent.height()))
        # Animation end
        # Opacity animation
        self.opacity_animation_e = QPropertyAnimation(self.effect, b"opacity")
        self.opacity_animation_e.setDuration(duration)
        self.opacity_animation_e.setStartValue(1.0)
        self.opacity_animation_e.setEndValue(0.0)
        # X animation
        self.x_animation_e = QPropertyAnimation(self, b"geometry")
        self.x_animation_e.setDuration(duration)
        self.x_animation_e.setStartValue(QRect(0, 0, parent.width(),
                                               parent.height()))
        self.x_animation_e.setEndValue(QRect(-x, 0, parent.width(),
                                             parent.height()))

        # Group animation start
        self.group_animation_s = QParallelAnimationGroup()
        self.group_animation_s.addAnimation(self.opacity_animation_s)
        self.group_animation_s.addAnimation(self.x_animation_s)

        # Group animation end
        self.group_animation_e = QParallelAnimationGroup()
        self.group_animation_e.addAnimation(self.opacity_animation_e)
        self.group_animation_e.addAnimation(self.x_animation_e)

        # Connections
开发者ID:centaurialpha,项目名称:pireal,代码行数:70,代码来源:preferences.py

示例14: CoolToolButton

# 需要导入模块: from PyQt5.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt5.QtCore.QPropertyAnimation import setEndValue [as 别名]
class CoolToolButton(QToolButton):

    def __init__(self, action=None, parent=None):
        super().__init__(parent)

        self._fader = 0
        if action is not None:
            self.setDefaultAction(action)
        self.setAttribute(Qt.WA_Hover, True)
        self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)

    def _set_fader(self, value):
        self._fader = value
        self.update()

    def _get_fader(self):
        return self._fader

    fader = pyqtProperty(float, fget=_get_fader, fset=_set_fader)

    def event(self, event):
        if event.type() == QEvent.Enter:
            self.anim = QPropertyAnimation(self, b"fader")
            self.anim.setDuration(150)
            self.anim.setEndValue(1.0)
            self.anim.start(QPropertyAnimation.DeleteWhenStopped)
        elif event.type() == QEvent.Leave:
            self.anim = QPropertyAnimation(self, b"fader")
            self.anim.setDuration(124)
            self.anim.setEndValue(0.0)
            self.anim.start(QPropertyAnimation.DeleteWhenStopped)
        else:
            return QToolButton.event(self, event)
        return False

    def paintEvent(self, event):
        painter = QPainter(self)
        if self.isEnabled() and not self.isDown() and not self.isChecked():
            painter.save()
            hover_color = QColor("#424242")
            faded_hover_color = QColor(hover_color)
            faded_hover_color.setAlpha(int(self._fader * hover_color.alpha()))
            painter.fillRect(event.rect(), faded_hover_color)
            painter.restore()
        elif self.isDown() or self.isChecked():
            painter.save()
            selected_color = QColor("#161719")
            painter.fillRect(event.rect(), selected_color)
            painter.restore()

        is_titled = bool(self.defaultAction().property("titled"))
        icon_rect = QRect(0, 0, 32, 32)
        icon_rect.moveCenter(event.rect().center())

        if is_titled:
            font = painter.font()
            center_rect = event.rect()
            font.setPointSizeF(6)
            fm = QFontMetrics(font)
            line_height = fm.height()
            text_flags = Qt.AlignHCenter | Qt.AlignTop
            project_name = self.defaultAction().property("heading")
            if project_name is not None:
                center_rect.adjust(0, line_height, 0, 0)
                icon_rect.moveTop(center_rect.top())
            else:
                icon_rect.moveCenter(center_rect.center())
            self.icon().paint(painter, icon_rect, Qt.AlignCenter)
            painter.setFont(font)
            r = QRect(0, 5, self.rect().width(), line_height)
            painter.setPen(Qt.white)
            margin = 5
            available_width = r.width() - margin
            ellided_project_name = fm.elidedText(
                project_name, Qt.ElideMiddle, available_width)
            painter.drawText(r, text_flags, ellided_project_name)
        else:
            self.icon().paint(painter, icon_rect, Qt.AlignCenter)

    def sizeHint(self):
        button_size = self.iconSize().expandedTo(QSize(48, 48))
        return button_size

    def minimumSizeHint(self):
        return QSize(8, 8)
开发者ID:ninja-ide,项目名称:ninja-ide,代码行数:87,代码来源:ui_tools.py

示例15: Tile

# 需要导入模块: from PyQt5.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt5.QtCore.QPropertyAnimation import setEndValue [as 别名]
class Tile(QLabel):
    moved = pyqtSignal()

    def __init__(self, parent=None):
        super(Tile, self).__init__(parent)
        self.isEmpty = False
        self.perfectPos = None
        self.hasPerfectPos = True
        self.moveEnabled = False

    def mousePressEvent(self, event):
        if not self.moveEnabled:
            return
        if self.switch():
            self.moved.emit()

    def switch(self, anim=True):
        var = False
        for neighbor in self.getNeighbors():
            if neighbor.isEmpty:
                Xself = self.pos().x()
                Yself = self.pos().y()
                Xneigh = neighbor.pos().x()
                Yneigh = neighbor.pos().y()
                if self.perfectPos.x() == Xneigh and \
                   self.perfectPos.y() == Yneigh:
                    self.hasPerfectPos = True
                else:
                    self.hasPerfectPos = False
                if neighbor.perfectPos.x() == Xself and \
                   neighbor.perfectPos.y() == Yself:
                    neighbor.hasPerfectPos = True
                else:
                    neighbor.hasPerfectPos = False
                if anim:
                    self.animation = QPropertyAnimation(self, "geometry")
                    self.animation.setDuration(200)
                    self.animation.setEndValue(QRect(Xneigh,
                                                     Yneigh,
                                                     self.width(),
                                                     self.height()))
                    self.animation.start()
                else:
                    self.move(Xneigh, Yneigh)
                neighbor.move(Xself, Yself)
                var = True
        return var

    def getNeighbors(self):
        neighbors = []
        x = self.pos().x()
        y = self.pos().y()
        if self.parent().childAt(x-1, y):
            neighbors.append(self.parent().childAt(x-1, y))
        if self.parent().childAt(x+41, y):
            neighbors.append(self.parent().childAt(x+41, y))
        if self.parent().childAt(x, y-1):
            neighbors.append(self.parent().childAt(x, y-1))
        if self.parent().childAt(x, y+41):
            neighbors.append(self.parent().childAt(x, y+41))
        return neighbors
开发者ID:Longhanks,项目名称:Tiles,代码行数:63,代码来源:tile.py


注:本文中的PyQt5.QtCore.QPropertyAnimation.setEndValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。