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


Python QPropertyAnimation.setEasingCurve方法代码示例

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


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

示例1: BaseDialog

# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setEasingCurve [as 别名]
class BaseDialog(QDialog):

    """ Base para popup dialog en la esquina superior derecha """

    def __init__(self, weditor):
        super(BaseDialog, self).__init__(weditor)
        self._weditor = weditor
        self.line = None
        # Popup
        self.setWindowFlags(Qt.Popup)
        # Posición
        self.qpoint = weditor.rect().topRight()
        self.global_point = weditor.mapToGlobal(self.qpoint)
        # Animación
        self._animation = QPropertyAnimation(self, "geometry")
        self._animation.setDuration(150)
        self._animation.setEasingCurve(QEasingCurve.Linear)

        key_escape = QShortcut(QKeySequence(Qt.Key_Escape), self)
        self.connect(key_escape, SIGNAL("activated()"), self._close)

    def showEvent(self, event):
        super(BaseDialog, self).showEvent(event)
        x, y = self.geometry().x(), self.geometry().y()
        self._animation.setStartValue(QRect(x, 0, self.width(), self.height()))
        self._animation.setEndValue(QRect(x, y, self.width(), self.height()))
        self._animation.start()
        self.line.setFocus()

    def _close(self):
        x, y = self.geometry().x(), self.geometry().y()
        self._animation.setStartValue(QRect(x, y, self.width(), self.height()))
        self._animation.setEndValue(QRect(x, 0, self.width(), self.height()))
        self._animation.start()
        self.connect(self._animation, SIGNAL("finished()"), self.close)
开发者ID:Garjy,项目名称:edis,代码行数:37,代码来源:base_dialog.py

示例2: createAnimationFromToFor

# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setEasingCurve [as 别名]
 def createAnimationFromToFor(widget, fromValue, toValue, duration, propName, curve=QEasingCurve.InOutCubic):
     anim = QPropertyAnimation(widget, propName)
     anim.setDuration(duration)
     anim.setStartValue(fromValue)
     anim.setEndValue(toValue)
     anim.setEasingCurve(curve)
     return anim
开发者ID:zinedine,项目名称:pyMagic,代码行数:9,代码来源:scan_wizard.py

示例3: slideInWidget

# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setEasingCurve [as 别名]
    def slideInWidget(self, widget, direction=Automatic):
        if self.indexOf(widget) == -1 or widget is self.currentWidget():
            return

        if self._active:
            return

        self._active = True

        prev_widget = self.currentWidget()
        next_widget = widget

        if direction == self.Automatic:
            if self.indexOf(prev_widget) < self.indexOf(next_widget):
                direction = self.BottomToTop if self.verticalMode else self.RightToLeft
            else:
                direction = self.TopToBottom if self.verticalMode else self.LeftToRight

        width = self.frameRect().width()
        height = self.frameRect().height()

        # the following is important, to ensure that the new widget has correct geometry information when sliding in the first time
        next_widget.setGeometry(0, 0, width, height)

        if direction in (self.TopToBottom, self.BottomToTop):
            offset = QPoint(0, height if direction == self.TopToBottom else -height)
        elif direction in (self.LeftToRight, self.RightToLeft):
            offset = QPoint(width if direction == self.LeftToRight else -width, 0)

        # re-position the next widget outside of the display area
        prev_widget_position = prev_widget.pos()
        next_widget_position = next_widget.pos()

        next_widget.move(next_widget_position - offset)
        next_widget.show()
        next_widget.raise_()

        prev_widget_animation = QPropertyAnimation(prev_widget, "pos")
        prev_widget_animation.setDuration(self.animationDuration)
        prev_widget_animation.setEasingCurve(QEasingCurve(self.animationEasingCurve))
        prev_widget_animation.setStartValue(prev_widget_position)
        prev_widget_animation.setEndValue(prev_widget_position + offset)

        next_widget_animation = QPropertyAnimation(next_widget, "pos")
        next_widget_animation.setDuration(self.animationDuration)
        next_widget_animation.setEasingCurve(QEasingCurve(self.animationEasingCurve))
        next_widget_animation.setStartValue(next_widget_position - offset)
        next_widget_animation.setEndValue(next_widget_position)

        self._animation_group.clear()
        self._animation_group.addAnimation(prev_widget_animation)
        self._animation_group.addAnimation(next_widget_animation)
        self._animation_group.start()
开发者ID:scudella,项目名称:blink-qt,代码行数:55,代码来源:containers.py

示例4: trigger

# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setEasingCurve [as 别名]
    def trigger(self, ui):
        """
        Trigger this animation
        """
        damage_counter = DamageCounter(damage=str(self.damage),
                                       colour=self.colour,
                                       parent=ui)
        ui.view.scene().addItem(damage_counter)
        damage_counter.setZValue(zorder_counter)

        bounds = damage_counter.boundingRect()
        width = bounds.width()

        rand = Random()

        damage_counter.setPos((self.location[0] * 32
                               + 16 - (width / 2)
                               + rand.randint(-16, 16)) + self.offset[0],
                              self.location[1] * 32 + self.offset[1])

        animation = QSequentialAnimationGroup()

        moving = QPropertyAnimation(damage_counter.adapter,
                                    'y_location')
        moving.setDuration(750)
        moving.setStartValue(self.location[1] * 32 + self.offset[1])
        moving.setEndValue(self.location[1] * 32 - 32 + self.offset[1])
        curve = QEasingCurve(QEasingCurve.OutElastic)
        moving.setEasingCurve(curve)
        animation.addAnimation(moving)

        fading = QPropertyAnimation(damage_counter.adapter,
                                    'opacity')
        fading.setDuration(750)
        fading.setStartValue(1.0)
        fading.setEndValue(0.0)
        animation.addAnimation(fading)

        def clean_up():
            animation.stop()
            ui.animations.remove(animation)
            ui.view.items().remove(damage_counter)
            ui.remove_finished_animation()

        animation.finished.connect(clean_up)
        ui.animations.append(animation)

        animation.start()
开发者ID:tuturto,项目名称:pyherc,代码行数:50,代码来源:attack.py

示例5: groupAnimation

# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setEasingCurve [as 别名]
def groupAnimation(ws, btngroup):
    # 建立一个平行的动作组
    ag = QParallelAnimationGroup()
    for w in ws:
        tmpbtn = btngroup.button(int(w[0]))
        # 对于每个按钮, 都生成一个进入的动作
        a = QPropertyAnimation(tmpbtn, "alpha")
        a.setDuration(200)
        a.setKeyValueAt(0, 10)
        # a.setKeyValueAt(0.5, 200)
        a.setKeyValueAt(1, 255)
        a.setLoopCount(-1)
        a.setEasingCurve(QEasingCurve.OutQuad)
        # a.setStartValue(QRect(-100, w.y(), w.width(), w.height()))
        # a.setEndValue(w.geometry())
        # 添加到组里面去
        ag.addAnimation(a)
    return ag
开发者ID:iefan,项目名称:randstudent,代码行数:20,代码来源:randstudent4.py

示例6: HtmlViewerWidget

# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setEasingCurve [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)
开发者ID:nicklv,项目名称:Roam,代码行数:45,代码来源:htmlviewer.py

示例7: _start_animation

# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setEasingCurve [as 别名]
    def _start_animation(self, show=True):
        if not self.USE_ANIMATIONS:
            g = self.child.geometry()
            self.child_state = self.STATE_ANIMATING
            if show:
                g.setHeight(self.preferred_size.height())
            else:
                g.setHeight(0)
            self.child.setGeometry(g)
            self.mandated_size.setHeight(g.height())
            self.update()
            self.child_state = self.STATE_VISIBLE if show else self.STATE_HIDDEN
            return

        self.update()
        a = QPropertyAnimation(self.child, "geometry", self)
        g = self.child.geometry()
        g.setHeight(0)
        a.setStartValue(g)
        g.setHeight(self.preferred_size.height())
        a.setEndValue(g)
        a.setEasingCurve(QEasingCurve.OutQuad)
        a.setDuration(self.duration)

        def valueChanged(qv):
            r = qv.toRect()
            self.mandated_size.setHeight(r.height())
            self.update()

        connect(a, SIGNAL("valueChanged(QVariant)"), valueChanged)

        if not show:
            a.setDirection(a.Backward)
            connect(a, SIGNAL("finished()"), lambda: setattr(self, "child_state", self.STATE_HIDDEN))
        else:
            a.setDirection(a.Forward)
            connect(a, SIGNAL("finished()"), lambda: setattr(self, "child_state", self.STATE_VISIBLE))

        self.child_state = self.STATE_ANIMATING
        a.start(a.DeleteWhenStopped)
开发者ID:mnunberg,项目名称:yobot,代码行数:42,代码来源:gui_new.py

示例8: OutputTab

# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setEasingCurve [as 别名]
class OutputTab(QTabWidget):
    def __init__(self,parent):
        QTabWidget.__init__(self,parent)
        self.setTabBar(MyTabBar(self))
        self.setMaximumHeight(200)#260
        self.anim = QPropertyAnimation(self, "geometry")
        self.anim.setDuration(3000)
        self.anim.setStartValue(QRect(0,0,100,0))
        self.anim.setEndValue(QRect(0,0,100,200))
        self.anim.setEasingCurve(QEasingCurve.InOutQuad)
        
        if(config.hide() == 1):
            #self.setFixedHeight(200)
            self.timer = QTimer(self)
            self.timer.timeout.connect(self.close)
            #self.connect(self.tabBar(), SIGNAL("tabno"),self.pop_out)
            #self.connect(self.tabBar(), SIGNAL("enter"),self.enter_show)
            #self.connect(self.tabBar(), SIGNAL("leave"),self.leave_hide)
            self.hide()
        else:
            #self.setFixedHeight(200)
            self.hide()
        
    def pop_out(self,no):
        #print "Hover Over Output tab: ",no
        if(no != 2):
            self.setCurrentIndex(no)
        
    def enter_show(self):
        self.anim.start()
        self.show()
        
    def leave_hide(self):
        self.timer.start(2000)
        
    def close(self):
        #self.setFixedHeight(30)
        self.timer.stop()    
        
        
开发者ID:pyros2097,项目名称:SabelIDE,代码行数:40,代码来源:tab.py

示例9: ExplodingAnimation

# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setEasingCurve [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)
开发者ID:dhrosa,项目名称:empyre_old,代码行数:38,代码来源:animations.py

示例10: CImprovedStackWidget

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

#.........这里部分代码省略.........
        """

        if(idx > self.count()-1):
            if(self.__m_vertical):
                self.__direction = self.__SLIDE_TYPE.TOP2BOTTOM
            else:
                self.__direction = self.__SLIDE_TYPE.RIGHT2LEFT
            idx = (idx) % self.count()

        elif (idx<0):
            if(self.__m_vertical):
                self.__direction = self.__SLIDE_TYPE.BOTTOM2TOP
            else:
                self.__direction = self.__SLIDE_TYPE.LEFT2RIGHT
            idx = (idx + self.count()) % self.count()

        self.slideInWgt(self.widget(idx))

    def slideInWgt(self, widget):
        if self.__m_active:
            return    #se l'animazione e' attiva, nn faccio nulla.
        else:
            self.__m_active = True
        now = self.currentIndex()
        next = self.indexOf(widget)


        if(now==next):
            self.__m_active = False
            return
        elif(now < next):
            if(self.__m_vertical):
                dhint = self.__SLIDE_TYPE.TOP2BOTTOM
            else:
                dhint = self.__SLIDE_TYPE.RIGHT2LEFT

        else:
            if(self.__m_vertical):
                dhint = self.__SLIDE_TYPE.BOTTOM2TOP
            else:
                dhint = self.__SLIDE_TYPE.LEFT2RIGHT

        #=======================================================================
        # if(self.__direction == self.AUTOMATIC):
        #    self.__direction = dhint
        #=======================================================================
        self.__direction = dhint
        offsetX = self.frameRect().width()
        offsetY = self.frameRect().height()

        self.widget(next).setGeometry ( 0,  0, offsetX, offsetY )

        if (self.__direction==self.__SLIDE_TYPE.BOTTOM2TOP):
            offsetX=0
            offsetY=-offsetY
        elif (self.__direction==self.__SLIDE_TYPE.TOP2BOTTOM):
            offsetX=0
        elif (self.__direction==self.__SLIDE_TYPE.RIGHT2LEFT):
            offsetX=-offsetX
            offsetY=0
        elif (self.__direction==self.__SLIDE_TYPE.LEFT2RIGHT):
            offsetY=0


        pnext = self.widget(next).pos()
        pnow  = self.widget(now).pos()
        self.__m_pnow = pnow

        self.widget(next).move(pnext.x() - offsetX, pnext.y() - offsetY)
        self.widget(next).show()

        self.__animnow.setTargetObject(self.widget(now))
        self.__animnow.setDuration(self.__m_speed)
        self.__animnow.setEasingCurve(self.__m_animationtype)
        self.__animnow.setStartValue(QPoint(pnow.x(), pnow.y()))
        self.__animnow.setEndValue(QPoint(offsetX+pnow.x(), offsetY+pnow.y()))

        self.__animnext.setTargetObject(self.widget(next))
        self.__animnext.setDuration(self.__m_speed)
        self.__animnext.setEasingCurve(self.__m_animationtype)
        self.__animnext.setStartValue(QPoint(-offsetX+pnext.x(), offsetY+pnext.y()))
        self.__animnext.setEndValue(QPoint(pnext.x(), pnext.y()))

        self.__animgroup.addAnimation(self.__animnow)
        self.__animgroup.addAnimation(self.__animnext)

        self.__m_next=next
        self.__m_now=now
        self.__m_active=True
        self.__animgroup.start()

    def __animationDone(self):
        self.setCurrentIndex(self.__m_next)

        self.widget(self.__m_now).hide()

        self.widget(self.__m_now).move(self.__m_pnow)
        self.__m_active=False

        self.animationOk.emit()
开发者ID:Nerkyator,项目名称:pyQt_components,代码行数:104,代码来源:ImprovedStackWidget.py

示例11: CImprovedPanel

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

#.........这里部分代码省略.........
        self.__move_time = value

    def getMoveTime(self):
        return self.__move_time

    moveTime = QtCore.pyqtProperty("int", getMoveTime, setMoveTime)

    def setResizeTime(self, value):
        """ Sets animation resize time.
        @param value: animation time (duration) (msec)
        @type value: int
        """
        self.__resize_time = value

    def getResizeTime(self):
        return self.__resize_time

    resizeTime = QtCore.pyqtProperty("int", getResizeTime, setResizeTime)

    def moveTo(self, x, y):
        """ Move itself to a given point with the given animation in the given duration.
        @param x: X point coordinate
        @type x: int
        @param y: Y point coordinate
        @type y: int
        """
        if self.__is_moving:
            return
        self.__is_moving = True
        self.__starting_position = QPoint(self.pos())
        self.__moveAnimation = QPropertyAnimation(self, "pos", self)
        self.__moveAnimation.finished.connect(self.__on_finished_moving)
        self.__moveAnimation.setDuration(self.__move_time)
        self.__moveAnimation.setEasingCurve(self.__move_animation_type)
        self.__moveAnimation.setStartValue(self.__starting_position)
        self.__moveAnimation.setEndValue(QPoint(x, y))
        self.__moveAnimation.start()


    def hideLeft(self):
        """ Panel hides sliding on the left. The slide amount is equal to his width - 5px.
        """
        dest_x = self.geometry().x() - self.width() - 5
        dest_y = self.geometry().y()
        self.moveTo(dest_x, dest_y)

    def showFromLeft(self):
        """ Panel shows sliding from the left. The slide amount is equal to his width + 5px.
        """
        dest_x = self.geometry().x() + self.width() + 5
        dest_y = self.geometry().y()
        self.moveTo(dest_x, dest_y)

    def hideRight(self):
        """ Panel hides sliding on the right. The slide amount is equal to his width - 5px.
        """
        dest_x = self.geometry().x() + self.width() + 5
        dest_y = self.geometry().y()
        self.moveTo(dest_x, dest_y)

    def showFromRight(self):
        """ Panel shows sliding from the right. The slide amount is equal to his width + 5px.
        """
        dest_x = self.geometry().x() - self.width() - 5
        dest_y = self.geometry().y()
        self.moveTo(dest_x, dest_y)
开发者ID:Nerkyator,项目名称:pyQt_components,代码行数:70,代码来源:ImprovedPanel.py

示例12: CImprovedLabel

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

#.........这里部分代码省略.........

    fadeCoefficient = QtCore.pyqtProperty("double", getFadeCoefficient, setFadeCoefficient)

    def __on_fading_timer(self):
        if self.__selected_fade_type == self.__FADE_TYPE.OUT:
            if self.__opacity > 0:
                self.__opacity -= self.__opacity_fading_coefficient
                self.__opacity_effect.setOpacity(self.__opacity)
                self.setGraphicsEffect(self.__opacity_effect)
            else:
                self.__fading_timer.stop()

        if self.__selected_fade_type == self.__FADE_TYPE.IN:
            if self.__opacity <= 1.0:
                self.__opacity += self.__opacity_fading_coefficient
                self.__opacity_effect.setOpacity(self.__opacity)
                self.setGraphicsEffect(self.__opacity_effect)
            else:
                self.__fading_timer.stop()

    #FUNZIONI PER SCROLLING
    def __move_text_left(self):
        if self.__separator not in self.text():
            self.setText(self.text() + "    " + self.__separator + "    ")
        left = str(self.text())[:1]
        right = str(self.text())[1:]
        self.setText(right + left)

    def __on_scrolling_timer(self):
        self.__move_text_left()

    def scrollingText(self, scroll):
        """ Sets if the label have to scroll or not.
        @param scroll: scrolling right to left or not
        @type scroll: bool
        """
        self.__scrolling_timer.setInterval(self.__scroll_time)
        if scroll:
            self.__original_text = self.text()
            self.__scrolling_timer.start()
        else:
            self.__scrolling_timer.stop()
            self.setText(self.__original_text)

    def setScrollingTime(self, value):
        """ Sets scrolling time. Everytime interval is reached, string is scrolled to left by one char.
        @param value: scrolling time (msec)
        @type value: int
        """
        self.__scroll_time = value

    ## FUNZIONI PER SPOSTAMENTO VERSO PUNTO (ANIMATO)
    def setMoveAnimationType(self, animation_type):
        """ Sets move animation type.
        @param animation_type: animation type
        @type animation_type: QtEasingCurve
        """
        self.__move_animation_type = animation_type

    def getMoveAnimationType(self):
        return self.__move_animation_type


    #asd = QtCore.pyqtProperty("QEasingCurve", getMoveAnimationType, setMoveAnimationType)
    #sembra nn essere supportato per ora (06/05/2013)

    def setMoveTime(self, value):
        """ Sets animation moving time.
        @param value: animation time (duration) (msec)
        @type value: int
        """
        self.__move_time = value

    def moveTo(self, x, y):
        """ Move itself to a given point with the given animation in the given duration.
        @param x: X point coordinate
        @type x: int
        @param y: Y point coordinate
        @type y: int
        """
        self.__starting_position = QPoint(self.pos())
        self.__moveAnimation = QPropertyAnimation(self, "pos", self)
        self.__moveAnimation.setDuration(self.__move_time)
        self.__moveAnimation.setEasingCurve(self.__move_animation_type)
        self.__moveAnimation.setStartValue(self.__starting_position)
        self.__moveAnimation.setEndValue(QPoint(x, y))
        self.__moveAnimation.start()

    def returnToOriginalPoint(self):
        """ Label returns to its original position. The original position is stored when calling moveTo() method.
        """
        self.__moveAnimation = QPropertyAnimation(self, "pos", self)
        self.__moveAnimation.setDuration(self.__move_time)
        self.__moveAnimation.setEasingCurve(self.__move_animation_type)
        self.__moveAnimation.setStartValue(QPoint(self.pos().x(), self.pos().y()))
        self.__moveAnimation.setEndValue(self.__starting_position)
        self.__moveAnimation.start()

    def mousePressEvent(self, event):
        self.clicked.emit()
开发者ID:Nerkyator,项目名称:pyQt_components,代码行数:104,代码来源:ImprovedLabel.py

示例13: slideIn

# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setEasingCurve [as 别名]
 def slideIn(self, index, direction=Direction.Automatic):
     """
     Slides in the panel at the inputed index in the given
     direction for this widget.
     
     :param      index | <int>
                 direction | <XStackedWidget.Direction>
     
     :return     <bool> | success
     """
     # do not allow multiple slides while it is active
     if self._active:
         return False
     
     # determine the proper index to calculate
     invert = False
     if self.count() <= index:
         if not self.wrap():
             return False
         index = self.count() % index
         invert = True
     elif index < 0:
         if not self.wrap():
             return False
         index = self.count() + index
         invert = True
     
     # define the direction information
     if index == self.currentIndex():
         return False
     elif self.currentIndex() < index:
         if direction == XStackedWidget.Direction.Automatic:
             if self.isVerticalMode():
                 direction = XStackedWidget.Direction.BottomToTop
             else:
                 direction = XStackedWidget.Direction.RightToLeft
     else:
         if direction == XStackedWidget.Direction.Automatic:
             if self.isVerticalMode():
                 direction = XStackedWidget.Direction.TopToBottom
             else:
                 direction = XStackedWidget.Direction.LeftToRight
     
     # invert the animation if we are wrapping
     if invert:
         if direction == XStackedWidget.Direction.BottomToTop:
             direction = XStackedWidget.Direction.TopToBottom
         elif direction == XStackedWidget.Direction.TopToBottom:
             direction = XStackedWidget.Direction.BottomToTop
         elif direction == XStackedWidget.Direction.LeftToRight:
             direction = XStackedWidget.Direction.RightToLeft
         else:
             direction = XStackedWidget.Direction.LeftToRight
     
     self._active = True
     offset_x = self.frameRect().width()
     offset_y = self.frameRect().height()
     
     next_widget = self.widget(index)
     curr_widget = self.widget(self.currentIndex())
     
     next_widget.setGeometry(0, 0, offset_x, offset_y)
     
     if direction == XStackedWidget.Direction.BottomToTop:
         offset_x = 0
         offset_y = -offset_y
     elif direction == XStackedWidget.Direction.TopToBottom:
         offset_x = 0
     elif direction == XStackedWidget.Direction.RightToLeft:
         offset_x = -offset_x
         offset_y = 0
     elif direction == XStackedWidget.Direction.LeftToRight:
         offset_y = 0
     
     next_point = next_widget.pos()
     curr_point = curr_widget.pos()
     
     self._nextIndex = index
     self._lastIndex = self.currentIndex()
     self._lastPoint = QPoint(curr_point)
     
     next_widget.move(next_point.x()-offset_x, next_point.y()-offset_y)
     next_widget.raise_()
     next_widget.show()
     
     curr_anim = QPropertyAnimation(curr_widget, 'pos')
     curr_anim.setDuration(self.speed())
     curr_anim.setEasingCurve(self.animationType())
     curr_anim.setStartValue(curr_point)
     curr_anim.setEndValue(QPoint(curr_point.x()+offset_x,
                                  curr_point.y()+offset_y))
     
     next_anim = QPropertyAnimation(next_widget, 'pos')
     next_anim.setDuration(self.speed())
     next_anim.setEasingCurve(self.animationType())
     next_anim.setStartValue(QPoint(next_point.x()-offset_x,
                                    next_point.y()-offset_y))
     next_anim.setEndValue(next_point)
     
     anim_group = QParallelAnimationGroup(self)
#.........这里部分代码省略.........
开发者ID:satishgoda,项目名称:DPS_PIPELINE,代码行数:103,代码来源:xstackedwidget.py

示例14: CImprovedButton

# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setEasingCurve [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)

#.........这里部分代码省略.........
开发者ID:Nerkyator,项目名称:pyQt_components,代码行数:103,代码来源:ImprovedButton.py

示例15: ScreensharingToolbox

# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setEasingCurve [as 别名]
class ScreensharingToolbox(base_class, ui_class):
    exposedPixels = 3

    def __init__(self, parent):
        super(ScreensharingToolbox, self).__init__(parent)
        with Resources.directory:
            self.setupUi()
        parent.installEventFilter(self)
        self.animation = QPropertyAnimation(self, 'pos')
        self.animation.setDuration(250)
        self.animation.setDirection(QPropertyAnimation.Forward)
        self.animation.setEasingCurve(QEasingCurve.Linear) # or OutCirc with 300ms
        self.retract_timer = QTimer(self)
        self.retract_timer.setInterval(3000)
        self.retract_timer.setSingleShot(True)
        self.retract_timer.timeout.connect(self.retract)
        self.resize(self.size().expandedTo(self.toolbox_layout.minimumSize()))

    def setupUi(self):
        super(ScreensharingToolbox, self).setupUi(self)

        # fix the SVG icons, as the generated code loads them as pixmaps, losing their ability to scale -Dan
        scale_icon = QIcon()
        scale_icon.addFile(Resources.get('icons/scale.svg'), mode=QIcon.Normal, state=QIcon.Off)
        viewonly_icon = QIcon()
        viewonly_icon.addFile(Resources.get('icons/viewonly.svg'), mode=QIcon.Normal, state=QIcon.Off)
        screenshot_icon = QIcon()
        screenshot_icon.addFile(Resources.get('icons/screenshot.svg'), mode=QIcon.Normal, state=QIcon.Off)
        fullscreen_icon = QIcon()
        fullscreen_icon.addFile(Resources.get('icons/fullscreen.svg'), mode=QIcon.Normal, state=QIcon.Off)
        fullscreen_icon.addFile(Resources.get('icons/fullscreen-exit.svg'), mode=QIcon.Normal, state=QIcon.On)
        fullscreen_icon.addFile(Resources.get('icons/fullscreen-exit.svg'), mode=QIcon.Active, state=QIcon.On)
        fullscreen_icon.addFile(Resources.get('icons/fullscreen-exit.svg'), mode=QIcon.Disabled, state=QIcon.On)
        fullscreen_icon.addFile(Resources.get('icons/fullscreen-exit.svg'), mode=QIcon.Selected, state=QIcon.On)
        minimize_icon = QIcon()
        minimize_icon.addFile(Resources.get('icons/minimize.svg'), mode=QIcon.Normal, state=QIcon.Off)
        minimize_icon.addFile(Resources.get('icons/minimize-active.svg'), mode=QIcon.Active, state=QIcon.Off)
        close_icon = QIcon()
        close_icon.addFile(Resources.get('icons/close.svg'), mode=QIcon.Normal, state=QIcon.Off)
        close_icon.addFile(Resources.get('icons/close-active.svg'), mode=QIcon.Active, state=QIcon.Off)

        self.scale_action.setIcon(scale_icon)
        self.viewonly_action.setIcon(viewonly_icon)
        self.screenshot_action.setIcon(screenshot_icon)
        self.fullscreen_action.setIcon(fullscreen_icon)
        self.minimize_action.setIcon(minimize_icon)
        self.close_action.setIcon(close_icon)

        self.scale_button.setIcon(scale_icon)
        self.viewonly_button.setIcon(viewonly_icon)
        self.screenshot_button.setIcon(screenshot_icon)
        self.fullscreen_button.setIcon(fullscreen_icon)
        self.minimize_button.setIcon(minimize_icon)
        self.close_button.setIcon(close_icon)

        self.scale_button.setDefaultAction(self.scale_action)
        self.viewonly_button.setDefaultAction(self.viewonly_action)
        self.screenshot_button.setDefaultAction(self.screenshot_action)
        self.fullscreen_button.setDefaultAction(self.fullscreen_action)
        self.minimize_button.setDefaultAction(self.minimize_action)
        self.close_button.setDefaultAction(self.close_action)

        self.color_depth_button.clear()
        self.color_depth_button.addItem('Default Color Depth', ServerDefault)
        self.color_depth_button.addItem('TrueColor (24 bits)', TrueColor)
        self.color_depth_button.addItem('HighColor (16 bits)', HighColor)
        self.color_depth_button.addItem('LowColor (8 bits)', LowColor)

    def eventFilter(self, watched, event):
        if watched is self.parent() and event.type() == QEvent.Resize:
            new_x = (watched.width() - self.width()) / 2
            self.move(new_x, self.y())
            self.animation.setStartValue(QPoint(new_x, -self.height() + self.exposedPixels))
            self.animation.setEndValue(QPoint(new_x, 0))
        return False

    def enterEvent(self, event):
        super(ScreensharingToolbox, self).enterEvent(event)
        self.retract_timer.stop()
        self.expose()

    def leaveEvent(self, event):
        super(ScreensharingToolbox, self).leaveEvent(event)
        self.retract_timer.start()

    def paintEvent(self, event): # make the widget style aware
        option = QStyleOption()
        option.init(self)
        painter = QStylePainter(self)
        painter.drawPrimitive(QStyle.PE_Widget, option)

    def expose(self):
        if self.animation.state() == QPropertyAnimation.Running and self.animation.direction() == QPropertyAnimation.Forward:
            return
        elif self.animation.state() == QPropertyAnimation.Stopped and self.pos() == self.animation.endValue():
            return
        self.animation.setDirection(QPropertyAnimation.Forward)
        self.animation.start()

    def retract(self):
#.........这里部分代码省略.........
开发者ID:kevinlovesing,项目名称:blink-qt,代码行数:103,代码来源:vncviewer.py


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