當前位置: 首頁>>代碼示例>>Python>>正文


Python QtCore.QPropertyAnimation方法代碼示例

本文整理匯總了Python中PyQt5.QtCore.QPropertyAnimation方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QPropertyAnimation方法的具體用法?Python QtCore.QPropertyAnimation怎麽用?Python QtCore.QPropertyAnimation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtCore的用法示例。


在下文中一共展示了QtCore.QPropertyAnimation方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: getDetailInfo

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 別名]
def getDetailInfo(self):
        """點擊後進行動畫效果的: 顯示某歌曲的詳細信息。"""
        self.shortInfo.hide()
        self.detailInfo.show()

        self.showDetail = QPropertyAnimation(self, b"geometry")

        x = self.pos().x()
        y = self.pos().y()

        self.showDetail.setStartValue(QRect(x, y, self.width(), self.height()))
        # 獲取頂層父窗口的長度。
        self.showDetail.setEndValue(QRect(0, self.grandparent.header.height()+3, self.grandparent.width(), self.grandparent.mainContent.height()))
        self.showDetail.setDuration(300)
        self.showDetail.setEasingCurve(QEasingCurve.InBack)

        self.showDetail.start(QAbstractAnimation.DeleteWhenStopped)
        # 將該組件顯示在最前,默認會嵌入到父組件裏麵。
        self.raise_()

        self.setDetailInfo() 
開發者ID:HuberTRoy,項目名稱:MusicBox,代碼行數:23,代碼來源:player.py

示例2: getShortInfo

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 別名]
def getShortInfo(self):
        """返回到原來的縮略圖信息。"""
        self.detailInfo.hide()
        self.showShort = QPropertyAnimation(self, b"geometry")
        
        x = self.pos().x()
        y = self.pos().y()
        
        self.showShort.setStartValue(QRect(0, self.grandparent.header.height(), self.grandparent.width(), self.grandparent.mainContent.height()))
        self.showShort.setEndValue(QRect(0, self.grandparent.height()-64-self.parent.height(), self.grandparent.navigation.width(), 64))
        self.showShort.setDuration(300)
        self.showShort.setEasingCurve(QEasingCurve.InBack)
        
        self.showShort.start(QAbstractAnimation.DeleteWhenStopped)

        self.shortInfo.show()
        self.raise_() 
開發者ID:HuberTRoy,項目名稱:MusicBox,代碼行數:19,代碼來源:player.py

示例3: __init__

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 別名]
def __init__(self, parent):
        """
        Create property animations, sets the opacity to zero initially.

        :param parent:
        """
        super().__init__()
        if isinstance(parent, QtWidgets.QGraphicsItem):
            # create opacity effect
            self.effect = QtWidgets.QGraphicsOpacityEffect()
            self.effect.setOpacity(0)
            parent.setGraphicsEffect(self.effect)
            self.fade = QtCore.QPropertyAnimation(self.effect, 'opacity'.encode())  # encode is utf-8 by default
        elif isinstance(parent, QtWidgets.QWidget):
            parent.setWindowOpacity(0)
            self.fade = QtCore.QPropertyAnimation(parent, 'windowOpacity'.encode())  # encode is utf-8 by default
        else:
            raise RuntimeError('Type of parameter must be QtWidgets.QGraphicsItem or QtWidgets.QWidget.')

        # set start and stop value
        self.fade.setStartValue(0)
        self.fade.setEndValue(1)
        self.fade.finished.connect(self.finished)

        self.forward = True 
開發者ID:Trilarion,項目名稱:imperialism-remake,代碼行數:27,代碼來源:qt.py

示例4: __init__

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 別名]
def __init__(self, *args, stretch=1 / 3, direction=0, widget=None, **kwargs):
        super(CDrawer, self).__init__(*args, **kwargs)
        self.setWindowFlags(self.windowFlags(
        ) | Qt.FramelessWindowHint | Qt.Popup | Qt.NoDropShadowWindowHint)
        self.setAttribute(Qt.WA_StyledBackground, True)
        self.setAttribute(Qt.WA_TranslucentBackground, True)
        # 進入動畫
        self.animIn = QPropertyAnimation(
            self, duration=500, easingCurve=QEasingCurve.OutCubic)
        self.animIn.setPropertyName(b'pos')
        # 離開動畫
        self.animOut = QPropertyAnimation(
            self, duration=500, finished=self.onAnimOutEnd,
            easingCurve=QEasingCurve.OutCubic)
        self.animOut.setPropertyName(b'pos')
        self.animOut.setDuration(500)
        self.setStretch(stretch)        # 占比
        self.direction = direction      # 方向
        # 半透明背景
        self.alphaWidget = QWidget(
            self, objectName='CDrawer_alphaWidget',
            styleSheet='#CDrawer_alphaWidget{background:rgba(55,55,55,100);}')
        self.alphaWidget.setAttribute(Qt.WA_TransparentForMouseEvents, True)
        self.setWidget(widget)          # 子控件 
開發者ID:PyQt5,項目名稱:CustomWidgets,代碼行數:26,代碼來源:CDrawer.py

示例5: __init__

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 別名]
def __init__(self, y_pos, up=True):
        super().__init__()
        self.up = up
        self.y_pos = y_pos

        # For fun, let's blur the object
        blur = qtw.QGraphicsBlurEffect()
        blur.setBlurRadius(10)
        blur.setBlurHints(
            qtw.QGraphicsBlurEffect.AnimationHint)
        self.setGraphicsEffect(blur)

        # Animate the object
        self.animation = qtc.QPropertyAnimation(self, b'y')
        self.animation.setStartValue(y_pos)
        end = 0 if up else SCREEN_HEIGHT
        self.animation.setEndValue(end)
        self.animation.setDuration(1000)
        self.yChanged.connect(self.check_collision) 
開發者ID:PacktPublishing,項目名稱:Mastering-GUI-Programming-with-Python,代碼行數:21,代碼來源:tankity_tank_tank_tank.py

示例6: decrypt_content

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 別名]
def decrypt_content(self, data, password):
        self.progress = QProgressDialog("Trying to decrypt...", None, 0, 100)
        self.progress.show()
        self.animation = QPropertyAnimation(self.progress, b"value")
        self.animation.setDuration(5000)  # XXX
        self.animation.setStartValue(0)
        self.animation.setEndValue(99)
        self.animation.start()
        self.crypter = Crypter(data, password.encode())
        self.crypter_thread = QThread()
        self.crypter.moveToThread(self.crypter_thread)
        self.crypter.succeeded.connect(self.animation.stop)
        self.crypter.succeeded.connect(self.progress.close)
        self.crypter.succeeded.connect(self.on_decryption_succeeded)
        self.crypter.failed.connect(self.animation.stop)
        self.crypter.failed.connect(self.progress.close)
        self.crypter.failed.connect(self.on_decryption_failed)
        self.crypter_thread.started.connect(self.crypter.decrypt)
        self.crypter_thread.start() 
開發者ID:gridsync,項目名稱:gridsync,代碼行數:21,代碼來源:widgets.py

示例7: setFadeIn

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 別名]
def setFadeIn(self, v):
        """
        Set the screen to use a fade-in animation.

        Args:
            v (bool): If True, run the fade-in animation when its trigger is
                received. False will disable the animation.
        """
        if not v:
            self.animations.pop(FADE_IN_ANIMATION, None)
            return
        effect = QtWidgets.QGraphicsOpacityEffect(self)
        self.animations[FADE_IN_ANIMATION] = a = QtCore.QPropertyAnimation(
            effect, b"opacity"
        )
        a.setDuration(550)
        a.setStartValue(0)
        a.setEndValue(1)
        a.setEasingCurve(QtCore.QEasingCurve.OutQuad)
        self.setGraphicsEffect(effect) 
開發者ID:decred,項目名稱:tinydecred,代碼行數:22,代碼來源:screens.py

示例8: animategroup

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 別名]
def animategroup(self, widgets, color):
        self.changeanimationgroup = QParallelAnimationGroup()
        for widget in widgets:
            effect = QtWidgets.QGraphicsColorizeEffect(widget)
            widget.setGraphicsEffect(effect)
            anim = QtCore.QPropertyAnimation(effect, b"color")
            anim.setDuration(500)
            anim.setStartValue(QtGui.QColor(0, 0, 0))
            anim.setKeyValueAt(0.25, color)
            anim.setEndValue(QtGui.QColor(0, 0, 0))
            self.changeanimationgroup.addAnimation(anim)
        self.changeanimationgroup.start() 
開發者ID:HA6Bots,項目名稱:Automatic-Youtube-Reddit-Text-To-Speech-Video-Generator-and-Uploader,代碼行數:14,代碼來源:scripteditor.py

示例9: _perform_move

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 別名]
def _perform_move(self, a, pos):
        from PyQt5.QtCore import QPropertyAnimation
        # create animation for this move operation
        anim = QPropertyAnimation(a, b'pos')
        anim.setDuration(200)
        anim.setEndValue(pos)
        anim.start()
        # the QPropertyAnimation object must outlive this method, so we attach it to this instance
        # TODO we should really collect it afterwards, perhaps with a handler for the finished() signal...
        self.animations.append(anim) 
開發者ID:jefftrull,項目名稱:gdb_python_api,代碼行數:12,代碼來源:instrument_srs.py

示例10: _perform_swap

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 別名]
def _perform_swap(self, a, b):
        from PyQt5.QtCore import QPointF, QPropertyAnimation

        elt_a = self.elements[a]
        elt_b = self.elements[b]
        # update positions
        pos_a = elt_a.pos
        pos_b = elt_b.pos

        # animate the exchange: move in an arc above/below a point halfway between
        pos_between = (pos_a + pos_b) / 2
        pos_above = QPointF(pos_between.x(), -10)
        pos_below = QPointF(pos_between.x(), 50)
        anim_a = QPropertyAnimation(self.elements[a], b'pos')
        anim_b = QPropertyAnimation(self.elements[b], b'pos')
        anim_a.setDuration(400)
        anim_b.setDuration(400)
        anim_a.setKeyValueAt(0.5, pos_above)
        anim_b.setKeyValueAt(0.5, pos_below)
        anim_a.setKeyValueAt(1, pos_b)
        anim_b.setKeyValueAt(1, pos_a)
        anim_a.start()
        anim_b.start()
        self.animations.append(anim_a)
        self.animations.append(anim_b)

        # update elements list
        self.elements[a] = elt_b
        self.elements[b] = elt_a 
開發者ID:jefftrull,項目名稱:gdb_python_api,代碼行數:31,代碼來源:instrument_srs.py

示例11: __init__

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 別名]
def __init__(self, main_window, notes_only, contentView, parent=None):
        super(PliantDockWidget, self).__init__(parent)
        self.main_window = main_window
        self.notes_only = notes_only
        self.contentView = contentView
        self.current_annotation = None
        self.parent = parent

        # Models
        # The following models belong to the sideDock
        # bookmarkModel, bookmarkProxyModel
        # annotationModel
        # searchResultsModel
        self.bookmarkModel = None
        self.bookmarkProxyModel = None
        self.annotationModel = None
        self.searchResultsModel = None

        # References
        # All widgets belong to these
        self.bookmarks = None
        self.annotations = None
        self.search = None

        # Widgets
        # Except this one
        self.sideDockTabWidget = None

        # Animate appearance
        self.animation = QtCore.QPropertyAnimation(self, b'windowOpacity')
        self.animation.setStartValue(0)
        self.animation.setEndValue(1)
        self.animation.setDuration(200) 
開發者ID:BasioMeusPuga,項目名稱:Lector,代碼行數:35,代碼來源:dockwidgets.py

示例12: showTip

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 別名]
def showTip(self, text, color='#20c3ff'):
        if self.tipLabel is not None:
            self.tipLabel.show()
            self.tipLabel.setStyleSheet(
                "QLabel{background: %s;border:3px; color: #FFFFFF; border-radius: 5px}" % color)
            self.tipLabel.setText(text)
            eff = QGraphicsOpacityEffect(self)
            self.tipLabel.setGraphicsEffect(eff)
            self.animate = QPropertyAnimation(eff, "opacity")
            self.animate.setDuration(2000)
            self.animate.setStartValue(0.8)
            self.animate.setEndValue(0)
            self.animate.setEasingCurve(QEasingCurve.InCubic)
            self.animate.finished.connect(lambda: self.tipLabel.hide())
            self.animate.start() 
開發者ID:shuoGG1239,項目名稱:QCandyUi,代碼行數:17,代碼來源:WindowWithTitleBar.py

示例13: mouseReleaseEvent

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 別名]
def mouseReleaseEvent(self, event):  # pylint: disable=invalid-name
        super().mouseReleaseEvent(event)
        if event.button() == Qt.LeftButton:
            anim = QPropertyAnimation(self, b"offset", self)
            anim.setDuration(120)
            anim.setStartValue(self.offset)
            anim.setEndValue(self._end_offset[self.isChecked()]())
            anim.start() 
開發者ID:Scille,項目名稱:parsec-cloud,代碼行數:10,代碼來源:switch_button.py

示例14: change_show_input_cookie

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 別名]
def change_show_input_cookie(self):
        row_c = 4 if is_windows else 3
        if self.form.rowCount() < row_c:
            self.org_height = self.height()
            self.form.addRow(self.cookie_lb, self.cookie_ed)
            self.show_input_cookie_btn.setText("隱藏Cookie輸入框")
            self.change_height = None
            self.adjustSize()
        else:
            if not self.change_height:
                self.change_height = self.height()
            if self.cookie_ed.isVisible():
                self.cookie_lb.setVisible(False)
                self.cookie_ed.setVisible(False)
                self.show_input_cookie_btn.setText("顯示Cookie輸入框")
                start_height, end_height = self.change_height, self.org_height
            else:
                self.cookie_lb.setVisible(True)
                self.cookie_ed.setVisible(True)
                self.show_input_cookie_btn.setText("隱藏Cookie輸入框")
                start_height, end_height = self.org_height, self.change_height
            gm = self.geometry()
            x, y = gm.x(), gm.y()
            wd = self.width()
            self.animation = QPropertyAnimation(self, b'geometry')
            self.animation.setDuration(400)
            self.animation.setStartValue(QRect(x, y, wd, start_height))
            self.animation.setEndValue(QRect(x, y, wd, end_height))
            self.animation.start() 
開發者ID:rachpt,項目名稱:lanzou-gui,代碼行數:31,代碼來源:login.py

示例15: mousePressEvent

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QPropertyAnimation [as 別名]
def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            self.mover.setY(1)
            
            if event.pos().x() < Frame.VALOR / 2:
                self.mover.setX(Frame.MIN_VALOR)
            elif event.pos().x() > Frame.VALOR / 2:
                self.mover.setX(Frame.MAX_VALOR - self.parent.button.width())

            self.animacion = QPropertyAnimation(self.parent.button, b"pos")
            self.animacion.setDuration(150)
            self.animacion.setEndValue(self.mover)
            self.animacion.valueChanged.connect(self.actualizarEstado)
            self.animacion.finished.connect(self.emitirEstado)
            self.animacion.start(QAbstractAnimation.DeleteWhenStopped) 
開發者ID:andresnino,項目名稱:PyQt5,代碼行數:17,代碼來源:interruptorPalanca.py


注:本文中的PyQt5.QtCore.QPropertyAnimation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。