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


Python QPropertyAnimation.duration方法代码示例

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


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

示例1: ExplodingAnimation

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

示例2: ConnectionWidget

# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import duration [as 别名]
class ConnectionWidget(QWidget):
    def __init__(self, parent = None, connect_cb = None):
        QWidget.__init__(self, parent)
        self.widgets = connection_properties.Ui_connection_widget()
        w = self.widgets
        w.setupUi(self)
        self.container_height_exclusive = self.sizeHint().height() - self.widgets.proxy_params.sizeHint().height()
        self.combined_height = self.sizeHint().height()
        
        if HAS_QPROPERTY_ANIMATION:
            self.pp_show_animation = QPropertyAnimation(self, "size", self)
            self.pp_show_animation.setDuration(100)
            self.pp_show_animation.setStartValue(QSize(self.width(), self.container_height_exclusive))
            self.pp_show_animation.setEndValue(QSize(self.width(), self.combined_height))
            
            self.pp_hide_animation = QPropertyAnimation(self, "size", self)
            self.pp_hide_animation.setDuration(100)
            self.pp_hide_animation.setStartValue(QSize(self.width(), self.combined_height))
            self.pp_hide_animation.setEndValue(QSize(self.width(), self.container_height_exclusive))
        
        mkProtocolComboBox(w.w_improto)
        w.proxy_params.proxy_type_group = QButtonGroup(w.proxy_params)
        for i in ("http", "socks4", "socks5"):
            w.proxy_params.proxy_type_group.addButton(getattr(w, "proxy_type_" + i))
        self.connect_cb = connect_cb
        if connect_cb:
            signal_connect(w.w_connect, SIGNAL("clicked()"), self.submit)
            signal_connect(w.w_username, SIGNAL("returnPressed()"), self.submit)
            signal_connect(w.w_password, SIGNAL("returnPressed()"), self.submit)
        
        
        if HAS_QPROPERTY_ANIMATION:
            @QtCore.pyqtSlot("bool", name="setVisible")
            def proxy_setVisible(b):
                if b:
                    self.pp_show_animation.start()
                    QTimer.singleShot(self.pp_show_animation.duration(),
                                      lambda: type(w.proxy_params).setVisible(w.proxy_params, True))
                else:
                    self.pp_hide_animation.start()
                    type(w.proxy_params).setVisible(w.proxy_params, False)
            w.proxy_params.setVisible = proxy_setVisible

                
        def _hideEvent(e):
            if self.parent() and self.parent().layout():
                self.parent().layout().activate()
            type(w.proxy_params).hideEvent(w.proxy_params, e)
            
        w.proxy_params.hideEvent = _hideEvent
        w.proxy_params.setVisible(False)
        signal_connect(w.show_proxy_prefs, SIGNAL("toggled(bool)"), w.proxy_params.setVisible)
        self.setAutoFillBackground(True)
        w.proxy_params.setAutoFillBackground(False)
                        
    @property
    def visible_height(self):
        if not self.widgets.proxy_params.isVisible():
            return self.container_height_exclusive
        else:
            return self.combined_height
        
    def getValues(self):
        w = self.widgets
        username = self.widgets.w_username.text()
        password = self.widgets.w_password.text()
        if not (username and password):
            msg = QMessageBox()
            msg.setIcon(msg.Critical)
            msg.setText("Username or password is empty!")
            msg.setWindowTitle("Missing Input!")
            msg.exec_()
            return None
        improto = self.widgets.w_improto.model().index(self.widgets.w_improto.currentIndex(),
                                     0,QModelIndex()).data(Qt.UserRole).toPyObject()
        
        _d_proxy_params = {"proxy_host" : None, "proxy_port": None, "proxy_type" : None,
                           "proxy_username" : None, "proxy_password" : None}
        _d_proxy_params["proxy_host"] = str(w.proxy_host.text())
        if _d_proxy_params["proxy_host"]:
            _d_proxy_params["proxy_port"] = str(w.proxy_port.text())
            _d_proxy_params["proxy_type"] = str(w.proxy_params.proxy_type_group.checkedButton().text()).lower()
            _d_proxy_params["proxy_username"] = str(w.proxy_username.text())
            _d_proxy_params["proxy_password"] = str(w.proxy_password.text())
        return (username, password, improto, _d_proxy_params)
        
    def submit(self):
        ret = self.getValues()
        if ret:
            username, password, improto, proxy_params = ret
            self.connect_cb(username, password, improto, **proxy_params)
            
    def reset(self):
        self.widgets.w_username.setText("")
        self.widgets.w_password.setText("")
开发者ID:mnunberg,项目名称:yobot,代码行数:97,代码来源:gui_util.py

示例3: SplitterResizer

# 需要导入模块: from PyQt4.QtCore import QPropertyAnimation [as 别名]
# 或者: from PyQt4.QtCore.QPropertyAnimation import duration [as 别名]
class SplitterResizer(QObject):
    """An object able to control the size of a widget in a
    QSpliter instance.

    """

    def __init__(self, parent=None):
        QObject.__init__(self, parent)
        self.__splitter = None
        self.__widget = None
        self.__animationEnabled = True
        self.__size = -1
        self.__expanded = False
        self.__animation = QPropertyAnimation(self, "size_", self)

        self.__action = QAction("toogle-expanded", self, checkable=True)
        self.__action.triggered[bool].connect(self.setExpanded)

    def setSize(self, size):
        """Set the size of the controlled widget (either width or height
        depending on the orientation).

        """
        if self.__size != size:
            self.__size = size
            self.__update()

    def size(self):
        """Return the size of the widget in the splitter (either height of
        width) depending on the splitter orientation.

        """
        if self.__splitter and self.__widget:
            index = self.__splitter.indexOf(self.__widget)
            sizes = self.__splitter.sizes()
            return sizes[index]
        else:
            return -1

    size_ = Property(int, fget=size, fset=setSize)

    def setAnimationEnabled(self, enable):
        """Enable/disable animation.
        """
        self.__animation.setDuration(0 if enable else 200)

    def animationEnabled(self):
        return self.__animation.duration() == 0

    def setSplitterAndWidget(self, splitter, widget):
        """Set the QSplitter and QWidget instance the resizer should control.

        .. note:: the widget must be in the splitter.

        """
        if splitter and widget and not splitter.indexOf(widget) > 0:
            raise ValueError("Widget must be in a spliter.")

        if self.__widget:
            self.__widget.removeEventFilter()
        self.__splitter = splitter
        self.__widget = widget

        if widget:
            widget.installEventFilter(self)

        self.__update()

    def toogleExpandedAction(self):
        """Return a QAction that can be used to toggle expanded state.
        """
        return self.__action

    def open(self):
        """Open the controlled widget (expand it to it sizeHint).
        """
        self.__expanded = True
        self.__action.setChecked(True)

        if not (self.__splitter and self.__widget):
            return

        size = self.size()
        if size > 0:
            # Already has non zero size.
            return

        hint = self.__widget.sizeHint()

        if self.__splitter.orientation() == Qt.Vertical:
            end = hint.height()
        else:
            end = hint.width()

        self.__animation.setStartValue(0)
        self.__animation.setEndValue(end)
        self.__animation.start()

    def close(self):
        """Close the controlled widget (shrink to size 0).
#.........这里部分代码省略.........
开发者ID:CHANAYA,项目名称:orange3,代码行数:103,代码来源:canvastooldock.py


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