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


Python QTimeLine.state方法代码示例

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


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

示例1: TransitionWidget

# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import state [as 别名]
class TransitionWidget(QWidget):
    """
    This class implements a transition effect between two pixmaps.

    Starts the transition with the method `start` and emit the signal finished()
    when the transition is done.
    """

    def __init__(self, parent):
        QWidget.__init__(self, parent)
        self._timeline = QTimeLine(400, self)
        self._blending_factor = 0.0
        self.connect(self._timeline, SIGNAL("valueChanged(qreal)"),
                     self._triggerRepaint)
        self.connect(self._timeline, SIGNAL("finished()"), SIGNAL("finished()"))

    def start(self, prev_pixmap, next_pixmap):
        self._prev_pixmap = prev_pixmap
        self._next_pixmap = next_pixmap
        self._timeline.start()

    def stop(self):
        self._timeline.stop()

    def _triggerRepaint(self, value):
        self._blending_factor = value
        self.update()

    def paintEvent(self, event):
        QWidget.paintEvent(self, event)
        if self._timeline.state() == QTimeLine.NotRunning:  # nothing to do
            return
        p = QPainter(self)
        p.setRenderHint(QPainter.SmoothPixmapTransform, True)
        p.drawPixmap(QPoint(0, 0), self._prev_pixmap)
        p.setOpacity(self._blending_factor)
        p.drawPixmap(QPoint(0, 0), self._next_pixmap)
开发者ID:develersrl,项目名称:devclient,代码行数:39,代码来源:gui_option.py

示例2: ParallaxSlide

# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import state [as 别名]
class ParallaxSlide(QGraphicsView):

    def __init__(self):
    
        QGraphicsView.__init__(self)
        self.ofs = 0
        self.factor = 1
        self.scene = QGraphicsScene()
        self.background = None
        self.icons = []
        self.iconTimeLine = QTimeLine()
        self.backgroundTimeLine = QTimeLine()
        
        self.setScene(self.scene)
        
        self.background = self.scene.addPixmap(QPixmap(":/background.jpg"))
        self.background.setZValue(0.0)
        self.background.setPos(0, 0)
    
        for i in range(7):
            str = QString(":/icon%1.png").arg(i+1)
            icon = self.scene.addPixmap(QPixmap(str))
            icon.setPos(320+i*64, 400)
            icon.setZValue(1.0)
            self.icons.append(icon)
    
        self.setFixedSize(320, 480)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
    
        self.connect(self.iconTimeLine, SIGNAL("frameChanged(int)"), self, SLOT("moveIcons(int)"))
        self.iconTimeLine.setCurveShape(QTimeLine.EaseInOutCurve)
    
        self.connect(self.backgroundTimeLine, SIGNAL("frameChanged(int)"), self, SLOT("moveBackground(int)"))
        self.connect(self.backgroundTimeLine, SIGNAL("finished()"), self, SLOT("adjustParameters()"))
        self.backgroundTimeLine.setCurveShape(QTimeLine.EaseInOutCurve)
        
        self.controls = Ui_ControlsForm()
        
        toolWidget = QWidget(self)
        toolWidget.setWindowFlags(Qt.Tool | Qt.WindowTitleHint)
        self.controls.setupUi(toolWidget)
        toolWidget.show()
    
        self.connect(self.controls.speedSlider, SIGNAL("valueChanged(int)"),
                     self, SLOT("adjustParameters()"))
        self.connect(self.controls.normalButton, SIGNAL("clicked()"),
                     self, SLOT("adjustParameters()"))
        self.connect(self.controls.parallaxButton, SIGNAL("clicked()"),
                     self, SLOT("adjustParameters()"))
        self.connect(self.controls.leftButton, SIGNAL("clicked()"),
                     self, SLOT("slideLeft()"))
        self.connect(self.controls.rightButton, SIGNAL("clicked()"),
                     self, SLOT("slideRight()"))
    
        self.slideBy(-320)
        self.adjustParameters()
    
    @pyqtSignature("")
    def slideLeft(self):
    
        if self.iconTimeLine.state() != QTimeLine.NotRunning:
            return
        
        if self.ofs > -640:
            self.slideBy(-320)
    
    @pyqtSignature("")
    def slideRight(self):
    
        if self.iconTimeLine.state() != QTimeLine.NotRunning:
            return
        
        if self.ofs < 0:
            self.slideBy(320)
    
    @pyqtSignature("int")
    def slideBy(self, dx):
    
        iconStart = self.ofs
        iconEnd = self.ofs + dx
        self.iconTimeLine.setFrameRange(iconStart, iconEnd)
        self.iconTimeLine.start()
        
        backgroundStart = -320 - int((-320 - iconStart)/self.factor)
        backgroundEnd = -320 - int((-320 - iconEnd)/self.factor)
        self.backgroundTimeLine.setFrameRange(backgroundStart, backgroundEnd)
        self.backgroundTimeLine.start()
        
        self.ofs = iconEnd
    
    @pyqtSignature("bool")
    def setParallaxEnabled(self, p):
    
        if p:
            self.factor = 2
            self.setWindowTitle("Sliding - Parallax mode")
        else:
            self.factor = 1
            self.setWindowTitle("Sliding - Normal mode")
#.........这里部分代码省略.........
开发者ID:Tarzanello,项目名称:graphics-dojo-qt5,代码行数:103,代码来源:parallaxslide.py

示例3: MainManager

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

#.........这里部分代码省略.........
        self.securityDialog.setValues(self.securityValues)
        if self.securityDialog.exec_():
            self.securityValues = self.securityDialog.getValues()

    def slotSecurityChanged(self, index):
        method = str(self.ui.comboSecurityTypes.itemData(index).toString())
        if method == "none":
            # Hide security widgets
            self.ui.pushSecurity.hide()
            self.ui.lineKey.hide()
            self.ui.labelKey.hide()
            self.ui.checkShowPassword.hide()
            # Erase all security data
            self.securityValues = {}
        else:
            parameters = self.iface.authParameters(self.lastEditedPackage, method)
            if len(parameters) == 1 and parameters[0][2] in ["text", "pass"]:
                # Single text or password field, don't use dialog
                self.ui.pushSecurity.hide()
                # Show other fields
                self.ui.lineKey.show()
                self.ui.labelKey.show()
                self.ui.checkShowPassword.show()
                self.ui.labelKey.setText(parameters[0][1])
            else:
                # Too many fields, dialog required
                self.ui.pushSecurity.show()
                self.ui.lineKey.hide()
                self.ui.labelKey.hide()
                self.ui.checkShowPassword.hide()
                self.securityDialog.setFields(parameters)

    def refreshBrowser(self):
        if self.animator.state() != 0:
            # Refreshing browser when animator is active causes blindness
            if not self.refreshBrowser in self.animatorFinishHook:
                self.animatorFinishHook.append(self.refreshBrowser)
            return
        aa = time.time()
        self.ui.filterBox.clear()
        self.probedDevices = []
        menu = QtGui.QMenu(self)
        for package in self.packages:
            info = self.packages[package]
            devices = self.iface.devices(package)
            # Add filter menu entry
            if len(devices):
                self.ui.filterBox.addItem(info["name"], QVariant(package))
                if info["type"] == "wifi":
                    self.ui.filterBox.addItem(i18n("Available Profiles"), QVariant("essid"))
                    wifiScanner = WifiPopup(self)
                    self.ui.buttonScan.setMenu(wifiScanner)
            # Create devices menu entry
            if len(devices) > 0:
                # Create profile menu with current devices
                for device in devices.keys():
                    if self.packages[package]['type'] in ('net', 'wifi'):
                        menuItem = QtGui.QAction("%s - %s" % (self.packages[package]['name'], findInterface(device).name), self)
                        menuItem.setData(QVariant("%s::%s" % (package,device)))
                        self.connect(menuItem, SIGNAL("triggered()"), self.createConnection)
                        # Store a list of probed devices
                        if device not in self.probedDevices:
                            self.probedDevices.append(device)
                        menu.addAction(menuItem)
                menu.addSeparator()
            if self.packages[package]['type'] == 'dialup':
开发者ID:Tayyib,项目名称:uludag,代码行数:70,代码来源:base.py

示例4: ItemMovel

# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import state [as 别名]
class ItemMovel(QGraphicsWidget):
    rectChanged = pyqtSignal()

    def __init__(self, moveX=True, moveY=True, rect=QRectF(0, 0, 30, 30), parent=None):
        super().__init__(parent)

        self._movel = Movel(moveX, moveY, self)
        self.installEventFilter(self._movel)

        self._newPos = QPointF()
        self._oldPos = QPointF()

        self._rect = QRectF()
        self._newRect = QRectF()
        self._oldRect = QRectF()

        self._timePos = QTimeLine(1000)
        self._timePos.setCurveShape(QTimeLine.EaseInOutCurve)
        self._timePos.valueChanged.connect(self._atualizaPos)

        self._timeRect = QTimeLine(1000)
        self._timeRect.valueChanged.connect(self._atualizaRect)

        self.setTamanho(rect)

    def setMoveXY(self, x, y):
        self._movel.setMoveXY(x, y)

    def getRect(self):
        return self._rect

    def setRect(self, rect):
        self._rect = rect
        self._atualizaGeometria()

    def boundingRect(self):
        return self._rect.adjusted(-1, -1, 1, 1)

    def altura(self):
        return self._newRect.height()

    def _atualizaPos(self, t):
        # Funcao da curva que parametriza um segmento AB
        # C(t) = A + (B - A)*t
        pos = self._oldPos + (self._newPos - self._oldPos) * t

        self.setPos(pos)
        self._atualizaGeometria()

    def _atualizaRect(self, t):
        oldP1 = self._oldRect.topLeft()
        oldP2 = self._oldRect.bottomRight()

        newP1 = self._newRect.topLeft()
        newP2 = self._newRect.bottomRight()

        p1 = oldP1 + (newP1 - oldP1) * t
        p2 = oldP2 + (newP2 - oldP2) * t

        self.setRect(QRectF(p1, p2))

    def _atualizaGeometria(self):
        self.setGeometry(QRectF(self.pos(), self.pos() + self._rect.bottomRight()))

    def goto(self, pos):
        if self.pos() == pos:
            return

        if self._timePos.state() == QTimeLine.Running:
            self._timePos.stop()

        self._oldPos = self.pos()
        self._newPos = pos
        self._timePos.start()

    def setTamanho(self, tam):
        if self._rect == tam:
            return

        if self._timeRect.state() == QTimeLine.Running:
            self._timeRect.stop()

        self._oldRect = self._rect
        self._newRect = tam
        self._timeRect.start()
        self.rectChanged.emit()

    def resize(self, size):
        if isinstance(size, QRect):
            size = size.size()

        self.setTamanho(QRectF(0, 0, size.width() - 3, self._newRect.height()))

    def paint(self, painter, widget, option):
        if self._timePos.state() == QTimeLine.Running:
            currentValue = self._timePos.currentValue()
            nextValue = self._timePos.valueForTime(self._timePos.currentTime() + 100)
            painter.setBrush(QColor(255, 0, 0, (nextValue - currentValue) * 150))

        painter.drawRoundedRect(self._rect, 7, 5)
开发者ID:tassio,项目名称:MensageiroQt,代码行数:102,代码来源:itens.py


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