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


Python QPropertyAnimation.setStartValue方法代码示例

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


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

示例1: BaseDialog

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

# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setStartValue [as 别名]
class CurrentSelection(QgsRubberBand):
    """
    Position marker for the current location in the viewer.
    """

    class AniObject(QObject):
        def __init__(self, band):
            super(CurrentSelection.AniObject, self).__init__()
            self.color = QColor()

        @pyqtProperty(int)
        def alpha(self):
            return self.color.alpha()

        @alpha.setter
        def alpha(self, value):
            self.color.setAlpha(value)

    def __init__(self, canvas):
        super(CurrentSelection, self).__init__(canvas)
        self.outline = QgsRubberBand(canvas)
        self.outline.setBrushStyle(Qt.NoBrush)
        self.outline.setWidth(5)
        self.outline.setIconSize(30)
        self.aniobject = CurrentSelection.AniObject(self)
        self.anim = QPropertyAnimation(self.aniobject, "alpha")
        self.anim.setDuration(500)
        self.anim.setStartValue(50)
        self.anim.setEndValue(100)
        self.anim.valueChanged.connect(self.value_changed)

    def setOutlineColour(self, color):
        self.outline.setColor(color)

    def setToGeometry(self, geom, layer):
        super(CurrentSelection, self).setToGeometry(geom, layer)
        self.outline.setToGeometry(geom, layer)
        self.anim.stop()
        self.anim.start()

    def reset(self, geomtype=QGis.Line):
        super(CurrentSelection, self).reset(geomtype)
        self.outline.reset(geomtype)
        self.anim.stop()

    def value_changed(self, value):
        self.setColor(self.aniobject.color)
        self.update()

    def setColor(self, color):
        self.aniobject.color = color
        super(CurrentSelection, self).setColor(color)
开发者ID:lydonchandra,项目名称:Roam,代码行数:54,代码来源:mapwidget.py

示例5: trigger

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

示例6: test

# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setStartValue [as 别名]
def test():
    # 动来动去的按钮
    button = QPushButton("Button")
    button.show()

    # 生成一个动画, 它会修改button的geometry属性
    animation = QPropertyAnimation(button, "geometry")
    # 动画时间是10秒
    animation.setDuration(10000)
    # 开始的位置
    animation.setStartValue(QRect(0, 0, 100, 30))
    # 结束的位置
    animation.setEndValue(QRect(250, 250, 100, 30))
    # 开始吧
    animation.start()

    app.exec_()
开发者ID:iefan,项目名称:randstudent,代码行数:19,代码来源:animation_ex1.py

示例7: HtmlViewerWidget

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

示例8: LineAnimation

# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setStartValue [as 别名]
class LineAnimation(Animation):
    def getPos(self):
        return self.__pos

    def setPos(self, pos):
        self.__pos = pos

    pos = pyqtProperty("QPointF", getPos, setPos)

    def __init__(self, p1, p2, color, duration, parent = None):
        super(LineAnimation, self).__init__(parent)
        self.startPoint = QPointF(p1[0], p1[1])
        self.endPoint = QPointF(p2[0], p2[1])
        self.__pos = self.startPoint
        self.color = color
        self.anim = QPropertyAnimation(self, "pos", self)
        self.anim.setStartValue(self.startPoint)
        self.anim.setEndValue(self.endPoint)
        self.anim.setDuration(duration)
        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 paint(self, painter):
        pen = QPen(Qt.black)
        pen.setWidthF(2.5)
        painter.setPen(pen)
        line = QLineF(self.startPoint, self.pos)
        painter.drawLine(line)
        if self.pos != self.startPoint:
            #draw arrowhead
            a = line.angle()
            l1 = QLineF.fromPolar(25, a - 155)
            l1.translate(self.pos)
            l2 = QLineF.fromPolar(25, a + 155)
            l2.translate(self.pos)
            painter.drawLine(l1)
            painter.drawLine(l2)
开发者ID:dhrosa,项目名称:empyre_old,代码行数:45,代码来源:animations.py

示例9: _start_animation

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

示例10: OutputTab

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

示例11: ExplodingAnimation

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

示例12: OverlayConnectionWidget

# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import setStartValue [as 别名]
class OverlayConnectionWidget(ConnectionWidget):
    def __init__(self, pos_fn, cb, parent=None):
        super(type(self), self).__init__(parent, cb)
        self.setAutoFillBackground(True)
        if HAS_QPROPERTY_ANIMATION:
            self.animation = QPropertyAnimation(self, "size", self)
        if HAS_GRAPHICS_EFFECT:
            self.effect = ShadowAndAlphaEffect(blur = 15.0, transparency = 0.90, parent = self)
            self.setGraphicsEffect(self.effect)
        self.pos_fn = pos_fn
        saved_size = None
        self._parent = parent
        
    def paintEvent(self, event):
        if self._parent:
            self.setFixedWidth(self._parent.width()-20)
        super(type(self), self).paintEvent(event)            
        painter = QPainter(self)
        qDrawShadePanel(painter, self.rect(), QPalette())
    if HAS_QPROPERTY_ANIMATION:
        def showEvent(self, event):
            super(type(self), self).showEvent(event)
            if not event.spontaneous():
                self.animation.setStartValue(QSize(self.width(), 0))
                self.animation.setEndValue(QSize(self.width(), self.visible_height))
                self.move(self.pos_fn())
                self.animation.start()
            
        def setVisible(self, b):
            if not b:
                self._animation = QPropertyAnimation(self, "size", self)
                self._animation.setEndValue(QSize(self.width(), 0))
                signal_connect(self._animation, SIGNAL("finished()"), lambda: super(type(self), self).setVisible(False))
                self._animation.start()
            else:
                super(type(self), self).setVisible(b)        
开发者ID:mnunberg,项目名称:yobot,代码行数:38,代码来源:gui_util.py

示例13: CImprovedButton

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

#.........这里部分代码省略.........
    fadeInterval = QtCore.pyqtProperty("int", getFadeTime, setFadeTime)

    def setFadeCoefficient(self, value):
        """ Sets fading coefficient. Alpha is increased (or decreased) by this value.
        @param value: coefficient (min 0.0 - max 1.0)
        @type value: float
        """
        self.__opacity_fading_coefficient = value

    def getFadeCoefficient(self):
        return self.__opacity_fading_coefficient

    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 GROW\SHRINK
    def __on_growed(self):
        self.__animationShrink.setStartValue(QSize(self.iconSize().width(), self.iconSize().height()))
        self.__animationShrink.setEndValue(
            QSize(self.iconSize().width() - self.__iconGrowsBy, self.iconSize().height() - self.__iconGrowsBy))
        self.__animationShrink.start()

    def __on_shrinked(self):
        self.__animationGrow.setStartValue(QSize(self.iconSize().width(), self.iconSize().height()))
        self.__animationGrow.setEndValue(
            QSize(self.iconSize().width() + self.__iconGrowsBy, self.iconSize().height() + self.__iconGrowsBy))
        self.__animationGrow.start()

    def startGrow(self):
        """
         Button ICON starts to grow and shrink to standard value when maximum size (configured) is reached
        """
        if self.__growing:
            return
        self.__animationGrow.setStartValue(QSize(self.iconSize().width(), self.iconSize().height()))
        self.__animationGrow.setEndValue(
            QSize(self.iconSize().width() + self.__iconGrowsBy, self.iconSize().height() + self.__iconGrowsBy))
        self.__animationGrow.start()
        self.__growing = True

    def stopGrow(self):
        if self.__animationGrow.startValue().toSize() != QSize(0,
                                                               0) and self.__animationShrink.startValue().toSize() != QPoint(
                0, 0):
            self.__animationGrow.stop()
            self.__animationShrink.stop()
            self.setIconSize(QSize(self.__defaultIconDimension, self.__defaultIconDimension))
            self.__growing = False
            
    #FUNZIONI PER BOUNCE
开发者ID:Nerkyator,项目名称:pyQt_components,代码行数:70,代码来源:ImprovedButton.py

示例14: MiniMap

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

    def __init__(self, parent):
        super(MiniMap, self).__init__(parent)
        self.setWordWrapMode(QTextOption.NoWrap)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setReadOnly(True)
        self.setCenterOnScroll(True)
        self.setMouseTracking(True)
        self.setTextInteractionFlags(Qt.NoTextInteraction)

        self._parent = parent
        self.highlighter = None
        styles.set_style(self, 'minimap')
        self.max_line = 0

        self.goe = QGraphicsOpacityEffect()
        self.setGraphicsEffect(self.goe)
        self.goe.setOpacity(settings.MINIMAP_MIN_OPACITY)
        self.animation = QPropertyAnimation(self.goe, "opacity")

    def __calculate_max(self):
        first_line = self._parent.firstVisibleBlock().blockNumber()
        last_line = self._parent._sidebarWidget.highest_line
        self.max_line = last_line - first_line
        self.update_visible_area()

    def set_code(self, source):
        self.setPlainText(source)
        self.__calculate_max()

    def adjust_to_parent(self):
        self.setFixedHeight(self._parent.height())
        self.setFixedWidth(self._parent.width() * settings.SIZE_PROPORTION)
        x = self._parent.width() - self.width()
        self.move(x, 0)
        fontsize = int(self.width() / settings.MARGIN_LINE)
        if fontsize < 1:
            fontsize = 1
        font = self.document().defaultFont()
        font.setPointSize(fontsize)
        self.setFont(font)
        self.__calculate_max()

    def update_visible_area(self):
        block = self._parent.firstVisibleBlock()
        first_line = block.blockNumber()
        max_count = self.blockCount()
        parent_cursor = self._parent.textCursor()
        parent_cursor.setPosition(block.position())
        self.setTextCursor(parent_cursor)
        lines_count = self.max_line
        if (first_line + self.max_line) > max_count:
            lines_count = max_count - first_line
        extraSelections = []
        for i in xrange(lines_count):
            selection = QTextEdit.ExtraSelection()
            lineColor = QColor(resources.CUSTOM_SCHEME.get('current-line',
                        resources.COLOR_SCHEME['current-line']))
            lineColor.setAlpha(100)
            selection.format.setBackground(lineColor)
            selection.format.setProperty(QTextFormat.FullWidthSelection, True)
            cursor = self.textCursor()
            cursor.setPosition(block.position())
            selection.cursor = cursor
            selection.cursor.clearSelection()
            extraSelections.append(selection)
            block = block.next()
        self.setExtraSelections(extraSelections)

    def enterEvent(self, event):
        self.animation.setDuration(300)
        self.animation.setStartValue(settings.MINIMAP_MIN_OPACITY)
        self.animation.setEndValue(settings.MINIMAP_MAX_OPACITY)
        self.animation.start()

    def leaveEvent(self, event):
        self.animation.setDuration(300)
        self.animation.setStartValue(settings.MINIMAP_MAX_OPACITY)
        self.animation.setEndValue(settings.MINIMAP_MIN_OPACITY)
        self.animation.start()

    def mousePressEvent(self, event):
        super(MiniMap, self).mousePressEvent(event)
        cursor = self.cursorForPosition(event.pos())
        self._parent.jump_to_line(cursor.blockNumber())
开发者ID:ntcong,项目名称:ninja-ide,代码行数:89,代码来源:minimap.py

示例15: NodeBodyItem

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

#.........这里部分代码省略.........
    def hoverLeaveEvent(self, event):
        self.__hover = False
        self.__updateShadowState()
        return GraphicsPathObject.hoverLeaveEvent(self, event)

    def paint(self, painter, option, widget):
        """
        Paint the shape and a progress meter.
        """
        # Let the default implementation draw the shape
        if option.state & QStyle.State_Selected:
            # Prevent the default bounding rect selection indicator.
            option.state = option.state ^ QStyle.State_Selected
        GraphicsPathObject.paint(self, painter, option, widget)

        if self.__progress >= 0:
            # Draw the progress meter over the shape.
            # Set the clip to shape so the meter does not overflow the shape.
            painter.setClipPath(self.shape(), Qt.ReplaceClip)
            color = self.palette.color(QPalette.ButtonText)
            pen = QPen(color, 5)
            painter.save()
            painter.setPen(pen)
            painter.setRenderHints(QPainter.Antialiasing)
            span = int(self.__progress * 57.60)
            painter.drawArc(self.__shapeRect, 90 * 16, -span)
            painter.restore()

    def __updateShadowState(self):
        if self.__hasFocus:
            color = QColor(FOCUS_OUTLINE_COLOR)
            self.setPen(QPen(color, 1.5))
        else:
            self.setPen(QPen(Qt.NoPen))

        radius = 3
        enabled = False

        if self.__isSelected:
            enabled = True
            radius = 7

        if self.__hover:
            radius = 17
            enabled = True

        if enabled and not self.shadow.isEnabled():
            self.shadow.setEnabled(enabled)

        if self.__animationEnabled:
            if self.__blurAnimation.state() == QPropertyAnimation.Running:
                self.__blurAnimation.pause()

            self.__blurAnimation.setStartValue(self.shadow.blurRadius())
            self.__blurAnimation.setEndValue(radius)
            self.__blurAnimation.start()
        else:
            self.shadow.setBlurRadius(radius)

    def __updateBrush(self):
        palette = self.palette
        if self.__isSelected:
            cg = QPalette.Active
        else:
            cg = QPalette.Inactive

        palette.setCurrentColorGroup(cg)
        c1 = palette.color(QPalette.Light)
        c2 = palette.color(QPalette.Button)
        grad = radial_gradient(c2, c1)
        self.setBrush(QBrush(grad))

    # TODO: The selected and focus states should be set using the
    # QStyle flags (State_Selected. State_HasFocus)

    def setSelected(self, selected):
        """
        Set the `selected` state.

        .. note:: The item does not have `QGraphicsItem.ItemIsSelectable` flag.
                  This property is instead controlled by the parent NodeItem.

        """
        self.__isSelected = selected
        self.__updateBrush()

    def setHasFocus(self, focus):
        """
        Set the `has focus` state.

        .. note:: The item does not have `QGraphicsItem.ItemIsFocusable` flag.
                  This property is instead controlled by the parent NodeItem.

        """
        self.__hasFocus = focus
        self.__updateShadowState()

    def __on_finished(self):
        if self.shadow.blurRadius() == 0:
            self.shadow.setEnabled(False)
开发者ID:pauloortins,项目名称:Computer-Vision-Classes---UFBA,代码行数:104,代码来源:nodeitem.py


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