Esempio n. 1
0
 def __init__(self, parent=None, wFlags=0):
     super(CustomProxy, self).__init__(parent, wFlags)
     self.popupShown = False
     self.currentPopup = None
     self.timeLine = QTimeLine(250, self)
     self.timeLine.valueChanged.connect(self.updateStep)
     self.timeLine.stateChanged.connect(self.stateChanged)
Esempio n. 2
0
    def __init__(self, parent=None, direction="ltr", rtf=False):
        """ Creates a new QPageWidget on given parent object. 

        parent: QWidget parent
        direction: "ltr" -> Left To Right
                   "ttb" -> Top To Bottom
        rtf: Return to first, if its True it flips to the first page 
             when next page requested at the last page
        """
        # First initialize, QPageWidget is based on QScrollArea
        QScrollArea.__init__(self, parent)

        # Properties for QScrollArea
        self.setFrameShape(QFrame.NoFrame)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setWidgetResizable(True)

        # Main widget, which stores all Pages in it
        self.widget = QWidget(self)

        # Layout based on QBoxLayout which supports Vertical or Horizontal layout
        if direction == "ltr":
            self.layout = QBoxLayout(QBoxLayout.LeftToRight, self.widget)
            self.__scrollBar = self.horizontalScrollBar()
            self.__base_value = self.width
        else:
            self.layout = QBoxLayout(QBoxLayout.TopToBottom, self.widget)
            self.__scrollBar = self.verticalScrollBar()
            self.__base_value = self.height
        self.layout.setSpacing(0)
        self.layout.setMargin(0)

        # Return to first
        self.__return_to_first = rtf

        # TMP_PAGE, its using as last page in stack
        # A workaround for a QScrollArea bug
        self.__tmp_page = Page(QWidget(self.widget))
        self.__pages = [self.__tmp_page]
        self.__current = 0
        self.__last = 0

        # Set main widget
        self.setWidget(self.widget)

        # Animation TimeLine
        self.__timeline = QTimeLine()
        self.__timeline.setUpdateInterval(2)

        # Updates scrollbar position when frame changed
        self.__timeline.frameChanged.connect(
            lambda x: self.__scrollBar.setValue(x))

        # End of the animation
        self.__timeline.finished.connect(self._animateFinished)

        # Initialize animation
        self.setAnimation()
        self.setDuration()
Esempio n. 3
0
    def move_to(self, nx_pos):
        """
        Move to corresponding position
        :param nx_pos:
        :return:
        """
        origin_x = self.x()
        origin_y = self.y()
        final_x = nx_pos[self.id][0]
        final_y = nx_pos[self.id][1]

        def frame_move(frame):
            value = self.timeline.valueForTime(self.timeline.currentTime())
            x = origin_x + (final_x - origin_x) * value
            y = origin_y + (final_y - origin_y) * value
            self.setPos(x, y)
            if self.scene():
                self.scene().node_moved.emit(self.id, x, y)

        def timeline_ends():
            self.setPos(final_x, final_y)
            self.timeline = None

        # Remember to hold the references to QTimeLine and QGraphicsItemAnimation instances.
        # They are not kept anywhere, even if you invoke QTimeLine.start().
        self.timeline = QTimeLine(1000)
        self.timeline.setFrameRange(0, 100)
        self.timeline.frameChanged.connect(frame_move)
        self.timeline.finished.connect(timeline_ends)

        self.timeline.start()
Esempio n. 4
0
        def animate_to(t, item, x, y, angle):
            # The QGraphicsItemAnimation class is used to
            # animate an item in specific ways
            # FIXME QGraphicsItemAnimation class is no longer supported.
            animation = QGraphicsItemAnimation()

            # You create a timeline (in this case, it is 1 second long
            timeline = QTimeLine(1000)

            # And it has 100 steps
            timeline.setFrameRange(0, 100)

            # I want that, at time t, the item be at point x,y
            animation.setPosAt(t, QPointF(x, y))

            # And it should be rotated at angle "angle"
            animation.setRotationAt(t, angle)

            # It should animate this specific item
            animation.setItem(item)

            # And the whole animation is this long, and has
            # this many steps as I set in timeline.
            animation.setTimeLine(timeline)

            # Here is the animation, use it.
            return animation
Esempio n. 5
0
    def __init__(self, *args, **kwargs):
        super(Window, self).__init__(*args, **kwargs)
        self.resize(600, 200)
        layout = QVBoxLayout(self)

        # 配置全局属性(也可以通过start方法里的参数配置单独的属性)
        CLoadingBar.config(height=2,
                           direction=CLoadingBar.TOP,
                           color='#2d8cf0',
                           failedColor='#ed4014')

        # 子控件顶部进度
        self.widget1 = QWidget(self)
        layout.addWidget(self.widget1)
        CLoadingBar.start(self.widget1, color='#19be6b', failedColor='#ff9900')

        widget = QWidget(self)
        layoutc = QHBoxLayout(widget)
        layoutc.addWidget(QPushButton('开始', self, clicked=self.doStart))
        layoutc.addWidget(QPushButton('结束', self, clicked=self.doFinish))
        layoutc.addWidget(QPushButton('错误', self, clicked=self.doError))
        layout.addWidget(widget)

        # 子控件底部进度
        self.widget2 = QWidget(self)
        layout.addWidget(self.widget2)
        CLoadingBar.start(self.widget2, direction=CLoadingBar.BOTTOM, height=6)

        # 模拟进度
        self.updateTimer = QTimeLine(10000,
                                     self,
                                     frameChanged=self.doUpdateProgress)
        self.updateTimer.setFrameRange(0, 100)
        # 设置数字变化曲线模拟进度的不规则变化
        self.updateTimer.setCurveShape(QTimeLine.EaseInOutCurve)
Esempio n. 6
0
    def __init__(self):
        super(Demo, self).__init__()
        self.resize(600, 600)

        self.label = QLabel('Hello PyQt5', self)
        self.label.move(-100, 100)

        self.timeline = QTimeLine(5000, self)
        self.timeline.setFrameRange(0, 700)
        self.timeline.frameChanged.connect(self.set_frame_func)
        self.timeline.stateChanged.connect(
            lambda: print(self.timeline.state()))  # 1
        self.timeline.setLoopCount(0)

        self.start_btn = QPushButton('Start', self)
        self.stop_btn = QPushButton('Stop', self)
        self.pause_btn = QPushButton('Pause', self)
        self.resume_btn = QPushButton('Resume', self)

        self.start_btn.clicked.connect(self.timeline.start)  # 2
        self.stop_btn.clicked.connect(self.timeline.stop)
        self.pause_btn.clicked.connect(lambda: self.timeline.setPaused(True))
        self.resume_btn.clicked.connect(self.timeline.resume)

        self.h_layout = QHBoxLayout()
        self.v_layout = QVBoxLayout()
        self.h_layout.addWidget(self.start_btn)
        self.h_layout.addWidget(self.stop_btn)
        self.h_layout.addWidget(self.pause_btn)
        self.h_layout.addWidget(self.resume_btn)
        self.v_layout.addStretch(1)
        self.v_layout.addLayout(self.h_layout)
        self.setLayout(self.v_layout)
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)
        self.setWindowTitle("Screen and Gaze Capture")
        grid = QGridLayout()
        layout_frame = QFrame()
        layout_frame.setLayout(grid)
        self.setCentralWidget(layout_frame)

        self.tracker_label = QLabel("No eye tracker connected.")
        grid.addWidget(self.tracker_label, 0, 0)

        connect_button = QPushButton("Connect to Eye Tracker")
        connect_button.pressed.connect(connect_to_tracker)
        grid.addWidget(connect_button, 1, 0)

        calibrate_button = QPushButton("Calibrate Eye Tracker")
        calibrate_button.pressed.connect(calibrate)
        grid.addWidget(calibrate_button, 2, 0)

        self.record_button = QPushButton("Record Screen and Gaze")
        self.record_button.pressed.connect(capture_screen)
        grid.addWidget(self.record_button, 3, 0)

        self.author_vid_button = QPushButton("Write Author Video")
        self.author_vid_button.pressed.connect(create_video)
        grid.addWidget(self.author_vid_button, 4, 0)
        self.author_vid_button.setEnabled(False)

        self.timeline = QTimeLine()
        self.timeline.setCurveShape(QTimeLine.LinearCurve)
        self.timeline.setDuration(360000)  #Totsl video lengthn in milliseconds
        self.timeline.setFrameRange(
            0, 7500)  #Maximum Frames in this video as 30 fps
        self.timeline.frameChanged.connect(update_frame)
        self.timeline.setUpdateInterval(10)  #Rate of Frame Capture
Esempio n. 8
0
 def __init__(self, parent=None):
     super(TimedProgressBar, self).__init__(parent, minimum=0, maximum=100)
     self._timeline = QTimeLine(updateInterval=100,
                                frameChanged=self.setValue)
     self._timeline.setFrameRange(0, 100)
     self._hideTimer = QTimer(timeout=self._done,
                              singleShot=True,
                              interval=3000)
Esempio n. 9
0
    def setupAnimation(self):

        self.timer = QTimeLine()
        self.timer.setLoopCount(0)
        self.timer.setFrameRange(0, 100)

        self.timer.frameChanged[int].connect(self.doStep)
        self.timer.start()
Esempio n. 10
0
 def __init__(self, *args, **kwargs):
     super(CCountUp, self).__init__(*args, **kwargs)
     self.isFloat = False  # 是否是小数
     font = self.font() or QFont()
     font.setBold(True)
     self.setFont(font)
     self.timeline = QTimeLine(6000, self)
     self.timeline.setEasingCurve(QEasingCurve.OutExpo)
     self.timeline.frameChanged.connect(self.onFrameChanged)
Esempio n. 11
0
 def __init__(self, parent = None):
     super().__init__()
     self.timer = QTimeLine(2000, self)
     #self.address = parent.address
     #self.port = parent.port
     self.address = "127.0.0.1"
     self.port = "5577"
     
     h1 = QHBoxLayout(None)
     self.yourLabel = QLabel(_("Your color:"), self)
     self.blackStone = QRadioButton(_("Black"), self)
     self.blackStone.setChecked(True)
     self.whiteStone = QRadioButton(_("White"), self)
     h1.addWidget(self.yourLabel)
     h1.addWidget(self.blackStone)
     h1.addWidget(self.whiteStone)
     
     h2 = QHBoxLayout(None)
     self.levelLabel = QLabel(_("Gnugo level:"), self)
     self.gnuLevel = QSpinBox(self)
     self.gnuLevel.setRange(1, 10)
     self.gnuLevel.setValue(8)
     h2.addWidget(self.levelLabel)
     h2.addWidget(self.gnuLevel)
     
     h3 = QHBoxLayout(None)
     self.komiLabel = QLabel(_("Set komi:"), self)
     self.komi = QSpinBox(self)
     self.komi.setEnabled(False)
     self.komi.setRange(0, 9)
     self.komi.setValue(0)
     h3.addWidget(self.komiLabel)
     h3.addWidget(self.komi)
     
     h4 = QHBoxLayout(None)
     self.startButton = QPushButton(_("Start Server"), self)
     buttonBox = QDialogButtonBox(self)
     self.okButton = QPushButton(_("OK"))
     self.okButton.setEnabled(False)
     self.cancelButton = QPushButton(_("Cancel"))
     buttonBox.addButton(self.okButton, QDialogButtonBox.AcceptRole)
     buttonBox.addButton(self.cancelButton, QDialogButtonBox.RejectRole)
     h4.addWidget(self.startButton)
     h4.addWidget(buttonBox)
     
     mainLayout = QVBoxLayout(None)
     mainLayout.addLayout(h1)
     mainLayout.addLayout(h2)
     mainLayout.addLayout(h3)
     mainLayout.addLayout(h4)
     self.setLayout(mainLayout)
     
     buttonBox.accepted.connect(self.accept)
     buttonBox.rejected.connect(self.reject)
     self.startButton.clicked.connect(self.startServer)
     self.timer.finished.connect(self.serverStarted)
Esempio n. 12
0
    def wheelEvent(self, event):
        numDegrees = event.angleDelta() / 8
        print("wheel: {}".format(numDegrees))
        numSteps = numDegrees.y() / 15
        self._numScheduledScalings += numSteps
        if self._numScheduledScalings * numSteps < 0:
            self._numScheduledScalings = numSteps

        anim = QTimeLine(350, self)
        anim.setUpdateInterval(20)
        anim.valueChanged.connect(self.ScalingTime)
        anim.finished.connect(self.AnimFinished)
        anim.start()
Esempio n. 13
0
    def __init__(self, old_widget, new_widget):

        QWidget.__init__(self, new_widget)
        self.old_pixmap = QPixmap(new_widget.size())
        old_widget.render(self.old_pixmap)
        self.pixmap_opacity = 1.0
        self.timeline = QTimeLine()
        self.timeline.valueChanged.connect(self.animate)
        self.timeline.finished.connect(self.close)
        self.timeline.setDuration(222)
        self.timeline.start()
        self.resize(new_widget.size())
        self.show()
Esempio n. 14
0
 def wheelEvent(self, event):
     # Check if zooming is enabled
     if not self.parent.menu.options[1].isChecked(): return
     # Zooming event on mouse scroll
     numDegrees = event.angleDelta() / 8
     numSteps = (numDegrees / 15).y()
     self._numScheduledScalings += numSteps
     if self._numScheduledScalings * numSteps < 0:
         self._numScheduledScalings = numSteps
     anim = QTimeLine(350, self)
     anim.setUpdateInterval(20)
     anim.valueChanged.connect(self.scalingTime)
     anim.finished.connect(self.animFinished)
     anim.start()
Esempio n. 15
0
    def __init__(self, old_widget, new_widget):

        QWidget.__init__(self, new_widget)

        self.old_pixmap = QPixmap(new_widget.size())
        old_widget.render(self.old_pixmap)

        self.pixmap_opacity = None
        self.timeline = QTimeLine(333, self)
        self.timeline.valueChanged.connect(self.animate)
        self.timeline.finished.connect(self.close)

        self.resize(new_widget.size())
        self.show()
Esempio n. 16
0
    def wheelEvent(self, event):
        numDegrees = event.angleDelta() / 8
        numSteps = numDegrees / 15
        self._numScheduledScalings += numSteps.y()
        """ if user moved the wheel in another direction, we reset previously scheduled scalings """
        if self._numScheduledScalings * numSteps.y() < 0:
            self._numScheduledScalings = numSteps.y()

        anim = QTimeLine(350, self)
        anim.setUpdateInterval(20)

        anim.valueChanged.connect(self.scalingTime)
        anim.finished.connect(self.animFinished)

        anim.start()
Esempio n. 17
0
    def zoom(self, numDegrees):
        numSteps = numDegrees / 15
        self._numScheduledScalings += numSteps

        if (
                self._numScheduledScalings * numSteps < 0
        ):  # if user moved the wheel in another direction, we reset previously scheduled scalings
            self._numScheduledScalings = numSteps

        anim = QTimeLine(350, self)
        anim.setUpdateInterval(20)

        anim.valueChanged.connect(self.scalingTime)
        anim.finished.connect(self.scaleAnimFinished)
        anim.start()
Esempio n. 18
0
    def openItem(self, item):
        if item == self.last_item:
            return

        if self.last_item:
            self.closeItem(self.last_item)

        self.animation = QTimeLine(ANIMATE_TIME, self)
        self.animation.setFrameRange(36, EXPANDED_SIZE)
        self.animation.frameChanged.connect(
            lambda x: item.setSizeHint(QSize(32, x)))
        self.animation.start()
        self.last_item = item
        self.animation.finished.connect(
            lambda: self.collectionList.setCurrentItem(item))
Esempio n. 19
0
    def translateVerticalEvent(self, dy):
        numSteps = dy * 20
        self._numScheduledVTranslations += numSteps

        if (
                self._numScheduledVTranslations * numSteps < 0
        ):  # if user moved the wheel in another direction, we reset previously scheduled scalings
            self._numScheduledVTranslations = numSteps

        if not self.animatingV:
            anim = QTimeLine(350, self)
            anim.setUpdateInterval(10)

            anim.valueChanged.connect(self.translateVTime)
            anim.finished.connect(self.translateVAnimFinished)
            anim.start()
Esempio n. 20
0
    def wheelEvent(self, event):
        degree = event.angleDelta().y() / 8
        step = degree / 15

        self.scheduledscaling = self.scheduledscaling + step

        animation = QTimeLine(350)
        animation.setUpdateInterval(20)
        animation.valueChanged.connect(
            animation.currentValue
        )  #Timeline does not start without this line, maybe a QT bug
        animation.valueChanged.connect(
            lambda: self.scale(1.0 + self.scheduledscaling / 300.0, 1.0 + self.
                               scheduledscaling / 300.0))
        animation.finished.connect(self.reset)
        animation.start()
Esempio n. 21
0
    def __init__(self):
        super(Widget, self).__init__()
        self.ui = Ui_SetupUsersWidget()
        self.ui.setupUi(self)

        self.edititemindex = None

        self.time_line = QTimeLine(400, self)
        self.time_line.setFrameRange(0, 220)
        self.time_line.frameChanged[int].connect(self.animate)

        self.ui.scrollArea.setFixedHeight(0)

        # User Icons
        self.normal_user_icon = QPixmap(":/gui/pics/users.png")
        self.super_user_icon = QPixmap(":/gui/pics/users.png")

        # Set disabled the create Button
        self.ui.createButton.setEnabled(False)

        # Connections
        self.ui.pass1.textChanged[str].connect(self.slotTextChanged)
        self.ui.pass2.textChanged[str].connect(self.slotTextChanged)
        self.ui.username.textChanged[str].connect(self.slotTextChanged)
        self.ui.realname.textChanged[str].connect(self.slotTextChanged)
        self.ui.username.textEdited[str].connect(self.slotUserNameChanged)
        self.ui.realname.textEdited[str].connect(self.slotRealNameChanged)
        self.ui.userID.valueChanged[int].connect(self.slotTextChanged)
        self.ui.userIDCheck.stateChanged[int].connect(self.slotuserIDCheck)
        self.ui.createButton.clicked.connect(self.slotCreateUser)
        self.ui.cancelButton.clicked.connect(self.resetWidgets)
        self.ui.deleteButton.clicked.connect(self.slotDeleteUser)
        self.ui.editButton.clicked.connect(self.slotEditUser)
        self.ui.addMoreUsers.clicked.connect(self.slotAdvanced)
        self.ui.userList.itemDoubleClicked[QListWidgetItem].connect(self.slotEditUser)
        self.ui.pass2.returnPressed.connect(self.slotReturnPressed)

        # focusInEvent is not a signal
        # self.ui.pass1.focusInEvent[QFocusEvent].connect(self.checkCapsLock)
        # self.ui.pass2.focusInEvent[QFocusEvent].connect(self.checkCapsLock)
        # self.ui.username.focusInEvent[QFocusEvent].connect(self.checkCapsLock)
        # self.ui.realname.focusInEvent[QFocusEvent].connect(self.checkCapsLock)

        ctx.installData.users = []
        ctx.installData.autoLoginUser = None
        self.user_name_changed = False
        self.used_ids = []
Esempio n. 22
0
 def __init__(self,
              parent=None,
              hideWhileIdle=True,
              hidden=False,
              showFinished=3000):
     super(TimedProgressBar, self).__init__(parent, minimum=0, maximum=100)
     self._hideWhileIdle = hideWhileIdle
     self._hidden = hidden
     self._showFinished = showFinished
     self._timeline = QTimeLine(updateInterval=100,
                                frameChanged=self.setValue)
     self._timeline.setFrameRange(0, 100)
     self._hideTimer = QTimer(timeout=self._done,
                              singleShot=True,
                              interval=showFinished)
     if not hidden and not hideWhileIdle:
         self.show()
Esempio n. 23
0
    def __init__(self):
        super(Robot, self).__init__()

        self.torsoItem = RobotTorso(self)
        self.headItem = RobotHead(self.torsoItem)
        self.upperLeftArmItem = RobotLimb(self.torsoItem)
        self.lowerLeftArmItem = RobotLimb(self.upperLeftArmItem)
        self.upperRightArmItem = RobotLimb(self.torsoItem)
        self.lowerRightArmItem = RobotLimb(self.upperRightArmItem)
        self.upperRightLegItem = RobotLimb(self.torsoItem)
        self.lowerRightLegItem = RobotLimb(self.upperRightLegItem)
        self.upperLeftLegItem = RobotLimb(self.torsoItem)
        self.lowerLeftLegItem = RobotLimb(self.upperLeftLegItem)

        self.timeline = QTimeLine()
        settings = [
            #             item               position    rotation at
            #                                 x    y    time 0  /  1
            (self.headItem, 0, -18, 20, -20),
            (self.upperLeftArmItem, -15, -10, 190, 180),
            (self.lowerLeftArmItem, 30, 0, 50, 10),
            (self.upperRightArmItem, 15, -10, 300, 310),
            (self.lowerRightArmItem, 30, 0, 0, -70),
            (self.upperRightLegItem, 10, 32, 40, 120),
            (self.lowerRightLegItem, 30, 0, 10, 50),
            (self.upperLeftLegItem, -10, 32, 150, 80),
            (self.lowerLeftLegItem, 30, 0, 70, 10),
            (self.torsoItem, 0, 0, 5, -20)
        ]
        self.animations = []
        for item, pos_x, pos_y, rotation1, rotation2 in settings:
            item.setPos(pos_x, pos_y)
            animation = QGraphicsItemAnimation()
            animation.setItem(item)
            animation.setTimeLine(self.timeline)
            animation.setRotationAt(0, rotation1)
            animation.setRotationAt(1, rotation2)
            self.animations.append(animation)
        self.animations[0].setScaleAt(1, 1.1, 1.1)

        self.timeline.setUpdateInterval(1000 / 25)
        self.timeline.setCurveShape(QTimeLine.SineCurve)
        self.timeline.setLoopCount(0)
        self.timeline.setDuration(2000)
        self.timeline.start()
Esempio n. 24
0
    def __init__(self, parent, width=14, height=12, numofchannel=6):
        super(TSScene, self).__init__(parent)

        # set waveform windows
        figure = Figure()
        figure.set_size_inches(width, height)
        self.graphwidth = figure.dpi * width
        self.canvas = FigureCanvas(figure)
        self.addWidget(self.canvas)
        self.canvas.mpl_connect('button_press_event',self.button_press_event)
        self.canvas.mpl_connect('button_release_event', self.button_release_event)
        self.canvas.mpl_connect('motion_notify_event', self.motion_notify_event)
        self.canvas.mpl_connect('scroll_event', self.scroll_event)

        self.axesavailability = [True for i in range(numofchannel)]
        self.axes = []
        for i in range(numofchannel):
            self.axes.append(figure.add_subplot(str(numofchannel)+'1'+str(i+1)))


        # set backend data model
        self.data = TSData()
        self.visibleWave = {}
        self.starttime = None
        self.endtime = None

        # prepare for user input
        self.downxcoord = None
        self.wheelactive = False
        self.rect = None

        self.installEventFilter(self)
        self.showgap = False
        self.downbutton = None
        self.currentxdata = None

        self.count = 0
        self.state = 'ready'

        self.timeline = QTimeLine(1)
        self.timeline.setCurrentTime(0)
        self.timeline.setUpdateInterval(1)
        self.timeline.finished.connect(self.timeshift)
        self.timeline.finished.connect(self.animfinished)
Esempio n. 25
0
    def __init__(self, size, color):
        super().__init__()

        self._loading_angle = 0
        self.width = 0
        self.color = color

        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setStyleSheet("background:transparent;")

        self.resize(size, size)
        self.center()
        self.initUI()

        timeline = QTimeLine(3000, self)
        timeline.setFrameRange(360, 0)
        timeline.frameChanged.connect(self.setLoadingAngle)
        timeline.start()
Esempio n. 26
0
    def __init__(self, size, color, side):
        super().__init__()

        self._next_step = 0
        self.width = 0
        self.color = color
        self.side = side

        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setStyleSheet("background:transparent;")

        self.resize(size, size)
        self.center()
        self.initUI()

        timeline = QTimeLine(3000, self)
        timeline.setFrameRange(size, 0)
        timeline.frameChanged.connect(self.setNextStep)
        timeline.start()
Esempio n. 27
0
    def createAndControl(self):
        newObject = 0
        className = self.theClassNames.at(self.theClassCombo.currentIndex())
        if (className == "QWidget"):
            newObject = QWidget()
        elif (className == "QPushButton"):
            newObject = QPushButton()
        elif (className == "QDialogButtonBox"):
            newObject = QDialogButtonBox()
        elif (className == "QTreeWidget"):
            newObject = QTreeWidget()
        elif (className == "QCalendarWidget"):
            newObject = QCalendarWidget()
        elif (className == "QAction"):
            newObject = QAction(None)
        elif (className == "QTimeLine"):
            newObject = QTimeLine()
        elif (className == "QTextDocument"):
            newObject = QTextDocument()

        if (not newObject):
            return

        newWidget = newObject
        if hasattr(newWidget, 'geometry'):
            r = newWidget.geometry()
            r.setSize(newWidget.sizeHint())
            r.setWidth(max(r.width(), 150))
            r.setHeight(max(r.height(), 50))
            r.moveCenter(QApplication.desktop().geometry().center())
            newWidget.setGeometry(r)
            newWidget.setWindowTitle(
                self.tr("Controlled Object: %s" % className))
            newWidget.show()

        if (self.theControlledObject):
            del self.theControlledObject

        self.theControlledObject = newObject
        self.theController.setObject(self.theControlledObject)
Esempio n. 28
0
    def wheelEvent(self, event: QWheelEvent) -> None:
        if event.modifiers() & Qt.ControlModifier:
            num_degrees = event.angleDelta().y() / 8.0
            num_steps = num_degrees / 15.0

            self.num_scheduled_steps += num_steps

            if self.num_scheduled_steps * num_steps < 0:
                self.num_scheduled_steps = num_steps

            animation = QTimeLine(duration=350, parent=self)
            animation.setUpdateInterval(20)

            value_changed_sig: pyqtBoundSignal = animation.valueChanged
            value_changed_sig.connect(self.scaling_step)

            finished_sig: pyqtBoundSignal = animation.finished
            finished_sig.connect(self.animation_finished)

            animation.start()
        else:
            super().wheelEvent(event)
    def __init__(self, *args, **kwargs):
        super(SideSlideDecorator, self).__init__(*args, **kwargs)

        self.resize(self.maximumSize())

        self.m_backgroundPixmap = QPixmap()

        self.m_slidePos = QPoint()
        self.m_timeline = QTimeLine()
        self.m_timeline.setDuration(260)
        self.m_timeline.setUpdateInterval(40)
        self.m_timeline.setEasingCurve(QEasingCurve.OutQuad)
        self.m_timeline.setStartFrame(0)
        self.m_timeline.setEndFrame(10000)

        self.m_decorationColor = QColor(0, 0, 0, 0)

        def frameChanged(_value):
            self.m_decorationColor = QColor(0, 0, 0, _value / 100)
            self.update()

        self.m_timeline.frameChanged.connect(frameChanged)
Esempio n. 30
0
    def __init__(self, direction=DirectionDown, duration=300, parent=None):
        """
        Constructor
        
        @param direction direction of the animation
        @type int (one of DirectionDown or DirectionUp)
        @param duration duration of the animation
        @type int
        @param parent reference to the parent widget
        @type QWidget
        """
        super(E5AnimatedWidget, self).__init__(parent)

        self.__direction = direction
        self.__stepHeight = 0.0
        self.__stepY = 0.0
        self.__startY = 0
        self.__widget = QWidget(self)

        self.__timeline = QTimeLine(duration)
        self.__timeline.setFrameRange(0, 100)
        self.__timeline.frameChanged.connect(self.__animateFrame)

        self.setMaximumHeight(0)