def __init__(self, parent=None): QStatusBar.__init__(self, parent) self.setAutoFillBackground( True) # set the widget background to be filled automatically # Define colours to use in animations red = QColor(255, 0, 0) red_transparent = QColor(255, 0, 0, alpha=0) green = QColor(0, 255, 0) green_transparent = QColor(0, 255, 0, alpha=0) # Setup fade out animation for red fade_out = QPropertyAnimation(self, b"back_color") fade_out.setStartValue(red) fade_out.setEndValue(red_transparent) fade_out.setDuration(2000) # Setup fade in animation for red fade_in = QPropertyAnimation(self, b"back_color") fade_in.setStartValue(red_transparent) fade_in.setEndValue(red) fade_in.setDuration(2000) # Setup stay animation for red stay_red = QPropertyAnimation(self, b"back_color") stay_red.setStartValue(red) stay_red.setEndValue(red) stay_red.setDuration(1000) # Setup animation group for no connection self._no_conn_anim = QSequentialAnimationGroup() self._no_conn_anim.addAnimation(fade_out) self._no_conn_anim.addAnimation(fade_in) self._no_conn_anim.addAnimation(stay_red) self._no_conn_anim.setLoopCount(-1) # loop infinitely # Setup fade out animation for green fade_out = QPropertyAnimation(self, b"back_color") fade_out.setStartValue(green) fade_out.setEndValue(green_transparent) fade_out.setDuration(2000) # Setup fade in animation for green fade_in = QPropertyAnimation(self, b"back_color") fade_in.setStartValue(green_transparent) fade_in.setEndValue(green) fade_in.setDuration(2000) # Setup stay animation for green stay_green = QPropertyAnimation(self, b"back_color") stay_green.setStartValue(green) stay_green.setEndValue(green) stay_green.setDuration(1000) # Setup animation group for a connection self._conn_anim = QSequentialAnimationGroup() self._conn_anim.addAnimation(fade_out) self._conn_anim.addAnimation(fade_in) self._conn_anim.addAnimation(stay_green) self._conn_anim.setLoopCount(-1)
def __init__(self, view): self.view = view self.nodes = [] self.edges = [] self.connections = [] self.directed_graph = Graph(directed=True) self.undirected_graph = Graph(directed=False) self.node_radius = 15 self.node_fieldRadius = 80 #self.graph_data = '' self.label_node_count = self.view.frame_graph.findChild(QLineEdit, 'lineEdit_node_count') self.DFS_sequential = QSequentialAnimationGroup() self.BFS_sequential = QSequentialAnimationGroup() self.DIJKSTRA_sequential = QSequentialAnimationGroup() self.sequential = QSequentialAnimationGroup() # Se atribuie cele 3 animatii ale algoritmilor animatiei de grup self.sequential.addAnimation(self.DFS_sequential) self.sequential.addAnimation(self.BFS_sequential) self.sequential.addAnimation(self.DIJKSTRA_sequential) self.gravity = True self.force_mode = False self.directed = False
def __init__(self, *args, pulse_unchecked_color="#44999999", pulse_checked_color="#4400B0EE", **kwargs): self._pulse_radius = 0 super().__init__(*args, **kwargs) self.animation = QPropertyAnimation(self, b"handle_position", self) self.animation.setEasingCurve(QEasingCurve.InOutCubic) self.animation.setDuration(200) # time in ms self.pulse_anim = QPropertyAnimation(self, b"pulse_radius", self) self.pulse_anim.setDuration(350) # time in ms self.pulse_anim.setStartValue(10) self.pulse_anim.setEndValue(20) self.animations_group = QSequentialAnimationGroup() self.animations_group.addAnimation(self.animation) self.animations_group.addAnimation(self.pulse_anim) self._pulse_unchecked_animation = QBrush(QColor(pulse_unchecked_color)) self._pulse_checked_animation = QBrush(QColor(pulse_checked_color))
def __init__(self): super(Demo, self).__init__() self.resize(600, 600) self.plane = QLabel(self) self.plane.resize(50, 50) self.plane.setPixmap(QPixmap('plane.gif').scaled( self.plane.size())) # 1 self.animation1 = QPropertyAnimation(self.plane, b'geometry') self.animation1.setDuration(2000) self.animation1.setStartValue(QRect(300, 500, 50, 50)) self.animation1.setEndValue(QRect(200, 400, 50, 50)) self.animation1.setLoopCount(1) self.animation2 = QPropertyAnimation(self.plane, b'geometry') self.animation2.setDuration(2000) self.animation2.setStartValue(QRect(200, 400, 50, 50)) self.animation2.setEndValue(QRect(400, 300, 50, 50)) self.animation2.setLoopCount(1) self.animation3 = QPropertyAnimation(self.plane, b'geometry') self.animation3.setDuration(2000) self.animation3.setStartValue(QRect(400, 300, 50, 50)) self.animation3.setEndValue(QRect(200, 200, 50, 50)) self.animation3.setLoopCount(1) self.animation_group = QSequentialAnimationGroup(self) # 2 self.animation_group.addAnimation(self.animation1) self.animation_group.addPause(1000) self.animation_group.addAnimation(self.animation2) self.animation_group.addAnimation(self.animation3) self.animation_group.start()
def start(self): height = self.height() width = self.width() for i in range(self._ball_numbers): self._seq_animations.append(QSequentialAnimationGroup(self)) # 增加间隔 self._seq_animations[i].addPause(self.duration_pause * i) # 第一段 par_animation1 = QParallelAnimationGroup(self) ra = RoundAnimation(self._balls[i], b'pos', self) ra.setEasingCurve(self.ec) ra.setDuration(self.duration) ra.setStartValue(QPoint(2 * self.ball_radius, 2 * self.ball_radius)) ra.setEndValue(QPoint(width - 2 * self.ball_radius, height - 2 * self.ball_radius)) par_animation1.addAnimation(ra) pa = QPropertyAnimation(self._balls[i], b'_style', self) pa.setEasingCurve(self.ec) pa.setDuration(self.duration) pa.setStartValue(0) pa.setKeyValueAt(0.5, 255) pa.setEndValue(0) par_animation1.addAnimation(pa) self._seq_animations[i].addAnimation(par_animation1) # 增加间隔 self._seq_animations[i].addPause(self.duration_pause * (self._ball_numbers - i - 1)) for seq in self._seq_animations: seq.setLoopCount(-1) seq.start(QAbstractAnimation.DeleteWhenStopped)
def __init__(self, state): super().__init__() self.interactive = False self.figures = copy.deepcopy(state.state) self.rows = len(self.figures) self.animationGroup = QSequentialAnimationGroup(self) self.initState(state)
def __init__(self, scatter): super(ScatterDataModifier, self).__init__() self.m_graph = scatter self.m_inputHandler = CustomInputHandler() self.m_graph.activeTheme().setType(Q3DTheme.ThemeDigia) self.m_graph.setShadowQuality(QAbstract3DGraph.ShadowQualityMedium) self.m_graph.scene().activeCamera().setCameraPreset( Q3DCamera.CameraPresetFront) self.m_graph.setAxisX(QValue3DAxis()) self.m_graph.setAxisY(QValue3DAxis()) self.m_graph.setAxisZ(QValue3DAxis()) self.m_graph.axisX().setRange(-10.0, 10.0) self.m_graph.axisY().setRange(-5.0, 5.0) self.m_graph.axisZ().setRange(-5.0, 5.0) series = QScatter3DSeries() series.setItemLabelFormat("@xLabel, @yLabel, @zLabel") series.setMesh(QAbstract3DSeries.MeshCube) series.setItemSize(0.15) self.m_graph.addSeries(series) self.m_animationCameraX = QPropertyAnimation( self.m_graph.scene().activeCamera(), 'xRotation') self.m_animationCameraX.setDuration(20000) self.m_animationCameraX.setStartValue(0.0) self.m_animationCameraX.setEndValue(360.0) self.m_animationCameraX.setLoopCount(-1) upAnimation = QPropertyAnimation(self.m_graph.scene().activeCamera(), 'yRotation') upAnimation.setDuration(9000) upAnimation.setStartValue(5.0) upAnimation.setEndValue(45.0) downAnimation = QPropertyAnimation(self.m_graph.scene().activeCamera(), 'yRotation') downAnimation.setDuration(9000) downAnimation.setStartValue(45.0) downAnimation.setEndValue(5.0) self.m_animationCameraY = QSequentialAnimationGroup() self.m_animationCameraY.setLoopCount(-1) self.m_animationCameraY.addAnimation(upAnimation) self.m_animationCameraY.addAnimation(downAnimation) self.m_animationCameraX.start() self.m_animationCameraY.start() self.m_graph.setActiveInputHandler(self.m_inputHandler) self.m_selectionTimer = QTimer() self.m_selectionTimer.setInterval(10) self.m_selectionTimer.timeout.connect(self.triggerSelection) self.m_selectionTimer.start()
def car_out(self, index): if index < self.cars.now_size: aq = QSequentialAnimationGroup(parent=self) for i in range(index + 1, self.cars.now_size): car = self.cars.pop() self.tmp_cars.push(car) a1 = self.move_animation(car, POS_X, car.py, POS_X, MOVE_Y) a2 = self.move_animation(car, POS_X, MOVE_Y, POS_TMP_X, MOVE_Y, 0.4) y = POS_TMP_Y + (self.tmp_cars.now_size - 1) * (DISTANCE + SHAPE) a3 = self.move_animation(car, POS_TMP_X, MOVE_Y, POS_TMP_X, y) car.px = POS_TMP_X car.py = y # aq = QSequentialAnimationGroup(parent=self) aq.addAnimation(a1) aq.addAnimation(a2) aq.addAnimation(a3) car = self.cars.pop() # 计算车费 self.lb_fare.setText(str(round(car.cost(),2))+" 元") a1 = self.move_animation(car, POS_X, car.py, POS_X, MOVE_Y) a2 = self.move_animation(car, POS_X, MOVE_Y, OUT_X, MOVE_Y) aq.addAnimation(a1) aq.addAnimation(a2) # 返回 for i in range(self.tmp_cars.now_size): car = self.tmp_cars.pop() self.cars.push(car) a1 = self.move_animation(car, POS_TMP_X, car.py, POS_TMP_X, MOVE_Y) a2 = self.move_animation(car, POS_TMP_X, MOVE_Y, POS_X, MOVE_Y, 0.4) y = POS_Y + (self.cars.now_size - 1) * (DISTANCE + SHAPE) a3 = self.move_animation(car, POS_X, MOVE_Y, POS_X, y) car.px = POS_X car.py = y aq.addAnimation(a1) aq.addAnimation(a2) aq.addAnimation(a3) if not self.wait_cars.is_empty(): car = self.wait_cars.pop() self.cars.push(car) car.clear_cost() a1 = self.move_animation(car, POS_Q_X, car.py, POS_Q_X, MOVE_Y, 0.4) a2 = self.move_animation(car, POS_Q_X, MOVE_Y, POS_X, MOVE_Y) y = POS_Y + (self.cars.now_size - 1) * (DISTANCE + SHAPE) a3 = self.move_animation(car, POS_X, MOVE_Y, POS_X, y) car.px = POS_X car.py = y aq.addAnimation(a1) aq.addAnimation(a2) aq.addAnimation(a3) for i in range(self.wait_cars.now_size): # print(self.wait_cars.now_size,len(self.wait_cars)) car = self.wait_cars.get(i) y = car.py + (DISTANCE + SHAPE) a1 = self.move_animation(car, POS_Q_X, car.py, POS_Q_X, y,0.5) car.py = y aq.addAnimation(a1) aq.start()
def __init__(self): super().__init__() # 记录所有模块 self.labels = [] self.order = [x for x in range(9)] self.group = QSequentialAnimationGroup() self.solutions = [] self.positions = [] # 求解器 self.sol = solution.Solution() self.initUI()
def __init__(self, letters, player, scene): super(Hand, self).__init__() self.player = player self.letters = letters # set of letters being used self.scene = scene self.extra_tiles = [] self.tilesinplay = [] # tiles being moved self.hand = [] # details of hand as (letter, tile) tuple self.group = QSequentialAnimationGroup() self.group.finished.connect(self.an_end)
def car_in(self): # car = Car(self, POS_Q_X, 0) # self.la.addWidget(car) # ret = self.cars.push(car) # 直接进入停车场 # print(ret) if not self.cars.is_full(): car = Car(self, POS_Q_X, 0) self.la.addWidget(car) self.cars.push(car) a1 = self.move_animation(car, POS_Q_X, 0, POS_Q_X, MOVE_Y) # a1.start() a2 = self.move_animation(car, POS_Q_X, MOVE_Y, POS_X, MOVE_Y) # 计算队伍位置 y = POS_Y + (self.cars.now_size - 1) * (DISTANCE + SHAPE) a3 = self.move_animation(car, POS_X, MOVE_Y, POS_X, y) car.px = POS_X car.py = y aq = QSequentialAnimationGroup(parent=self) aq.addAnimation(a1) aq.addAnimation(a2) aq.addAnimation(a3) aq.start() # print("动画") elif not self.wait_cars.is_full(): car = Car(self, POS_Q_X, 0) self.la.addWidget(car) self.wait_cars.push(car) # 进入排队 y = POS_Q_Y - (self.wait_cars.now_size - 1) * (DISTANCE + SHAPE) a1 = self.move_animation(car, POS_Q_X, 0, POS_Q_X, y) car.px = POS_Q_X car.py = y aq = QSequentialAnimationGroup(parent=self) aq.addAnimation(a1) aq.start() else: pass
def __init__(self, *args): super().__init__(*args) self.img = None self.thumb = None self.filename = None self.np_array = None self.status = ClassifiedImageBundle.UNDECIDED self.color = None self.keep = None self.show_buttons = False self._animation_progress = 1.0 self.ani = QSequentialAnimationGroup() self.init_animation()
def start(self): bh = self.height() / 2 - self._ball_radius width = self.width() for i in range(self._ball_numbers): self._seq_animations.append(QSequentialAnimationGroup(self)) # 增加间隔 self._seq_animations[i].addPause(self.duration_pause * i) # 第一段 par_animation1 = QParallelAnimationGroup(self) pa = QPropertyAnimation(self._balls[i], b'pos', self) pa.setEasingCurve(self._ec1) pa.setDuration(self.duration * self._first_flag) pa.setStartValue(QPoint(0, bh)) pa.setEndValue(QPoint(width * 0.4, bh)) par_animation1.addAnimation(pa) pa = QPropertyAnimation(self._balls[i], b'_style', self) pa.setEasingCurve(self._ec1) pa.setDuration(self.duration * self._first_flag) pa.setStartValue(0) pa.setEndValue(255) par_animation1.addAnimation(pa) self._seq_animations[i].addAnimation(par_animation1) # 第二段 pa = QPropertyAnimation(self._balls[i], b'pos', self) pa.setDuration(self.duration * self._second_flag) pa.setStartValue(QPoint(width * 0.4, bh)) pa.setEndValue(QPoint(width * 0.6, bh)) self._seq_animations[i].addAnimation(pa) # 第三段 par_animation2 = QParallelAnimationGroup(self) pa = QPropertyAnimation(self._balls[i], b'pos', self) pa.setEasingCurve(self._ec2) pa.setDuration(self.duration * self._three_flag) pa.setStartValue(QPoint(width * 0.6, bh)) pa.setEndValue(QPoint(width, bh)) par_animation2.addAnimation(pa) pa = QPropertyAnimation(self._balls[i], b'_style', self) pa.setEasingCurve(self._ec2) pa.setDuration(self.duration * self._three_flag) pa.setStartValue(255) pa.setEndValue(0) par_animation2.addAnimation(pa) self._seq_animations[i].addAnimation(par_animation2) # 增加间隔 self._seq_animations[i].addPause(self.duration_pause * (self._ball_numbers - i - 1)) for seq in self._seq_animations: seq.setLoopCount(-1) seq.start(QAbstractAnimation.DeleteWhenStopped)
def show_hide_menu(self, checked): animation_group = QSequentialAnimationGroup(self) for idx, target in enumerate(self.animation_target): animation = QPropertyAnimation() animation.setTargetObject(target) animation.setPropertyName(b"pos") animation.setEndValue(self.pushButton.pos()) animation.setStartValue(self.animation_target_pos[idx]) animation.setDuration(200) animation.setEasingCurve(QEasingCurve.InOutBounce) animation_group.addAnimation(animation) animation_group.setDirection(not checked) animation_group.start(QAbstractAnimation.DeleteWhenStopped)
def __init__(self, tetris, tetritile): super(QTetris.QTetritile, self).__init__() tetritile.delegate = self self.color = self.colorMap[type(tetritile.tetrimino)] self.tetris = tetris self.moveAnimation = QSequentialAnimationGroup() self.dropAnimation = QPropertyAnimation(self, b"pos") self.collapseAnimation = QPropertyAnimation(self, b"pos") self.shiftAnimation = QPropertyAnimation(self, b"pos") self.collapseAnimation.finished.connect( lambda tetritile=tetritile: self.tetris.disappearEvent( tetritile)) self.tetris.scene.addItem(self) self.setPos(QPointF(0, 4)) self.moveEvent(tetritile)
def __init__(self, parent=None, f=Qt.ToolTip | Qt.FramelessWindowHint): super(Notification, self).__init__(parent, f) self.parent = parent self.theme = self.parent.theme self.setObjectName('notification') self.setWindowModality(Qt.NonModal) self.setMinimumWidth(450) self._title, self._message = '', '' self._icons = dict() self.buttons = list() self.msgLabel = QLabel(self) self.msgLabel.setWordWrap(True) logo = QPixmap(82, 82) logo.load(':/images/vidcutter-small.png', 'PNG') logo_label = QLabel(self) logo_label.setPixmap(logo) self.left_layout = QVBoxLayout() self.left_layout.addWidget(logo_label) self.right_layout = QVBoxLayout() self.right_layout.addWidget(self.msgLabel) if sys.platform != 'win32': effect = QGraphicsOpacityEffect() effect.setOpacity(1) self.window().setGraphicsEffect(effect) self.animations = QSequentialAnimationGroup(self) self.pauseAnimation = self.animations.addPause( int(self.duration / 2 * 1000)) opacityAnimation = QPropertyAnimation(effect, b'opacity', self.animations) opacityAnimation.setDuration(2000) opacityAnimation.setStartValue(1.0) opacityAnimation.setEndValue(0.0) opacityAnimation.setEasingCurve(QEasingCurve.InOutQuad) self.animations.addAnimation(opacityAnimation) self.animations.finished.connect(self.close) self.shown.connect(self.fadeOut) else: self.shown.connect( lambda: QTimer.singleShot(self.duration * 1000, self.fadeOut)) layout = QHBoxLayout() layout.addStretch(1) layout.addLayout(self.left_layout) layout.addSpacing(10) layout.addLayout(self.right_layout) layout.addStretch(1) self.setLayout(layout)
def rain(pix, node): node.pix.setOriginPt() pos = node.pix.pos() sync = random.randint(17, 31) * 50 y = int(pos.y()) ViewH = common["ViewH"] bottom = y + ViewH + node.pix.height * 2 top = y + node.pix.height * 2 rain1 = QPropertyAnimation(node, b'pos') rain1.setDuration(sync) rain1.setStartValue(pos) rain1.setEndValue(pos + QPointF(0, bottom)) opacity1 = QPropertyAnimation(node, b'opacity') opacity1.setDuration(sync) opacity1.setStartValue(node.pix.opacity()) opacity1.setKeyValueAt(.10, .50) opacity1.setEndValue(0) par1 = QParallelAnimationGroup() par1.addAnimation(rain1) par1.addAnimation(opacity1) rain2 = QPropertyAnimation(node, b'pos') rain2.setDuration(sync) rain2.setStartValue(pos + QPointF(0, -top)) rain2.setEndValue(pos) opacity2 = QPropertyAnimation(node, b'opacity') opacity2.setDuration(sync) opacity2.setStartValue(node.pix.opacity()) opacity2.setEndValue(.85) par2 = QParallelAnimationGroup() par2.addAnimation(rain2) par2.addAnimation(opacity2) rain = QSequentialAnimationGroup() rain.addAnimation(par1) rain.addAnimation(par2) rain.setLoopCount(-1) return rain
def _initAnimations(self): for index in range(5): # 5个小圆 item = CircleItem(self) item.valueChanged.connect(self.update) # 串行动画组 seqAnimation = QSequentialAnimationGroup(self) seqAnimation.setLoopCount(-1) self._items.append((item, seqAnimation)) # 暂停延迟动画 seqAnimation.addAnimation(QPauseAnimation(150 * index, self)) # 加速,并行动画组1 parAnimation1 = QParallelAnimationGroup(self) # 透明度 parAnimation1.addAnimation(QPropertyAnimation( item, b'opacity', self, duration=400, startValue=0, endValue=1.0)) # x坐标 parAnimation1.addAnimation(QPropertyAnimation( item, b'x', self, duration=400, startValue=0, endValue=25.0)) seqAnimation.addAnimation(parAnimation1) ## # 匀速 seqAnimation.addAnimation(QPropertyAnimation( item, b'x', self, duration=2000, startValue=25.0, endValue=75.0)) # 加速,并行动画组2 parAnimation2 = QParallelAnimationGroup(self) # 透明度 parAnimation2.addAnimation(QPropertyAnimation( item, b'opacity', self, duration=400, startValue=1.0, endValue=0)) # x坐标 parAnimation2.addAnimation(QPropertyAnimation( item, b'x', self, duration=400, startValue=75.0, endValue=100.0)) seqAnimation.addAnimation(parAnimation2) ## # 暂停延迟动画 seqAnimation.addAnimation( QPauseAnimation((5 - index - 1) * 150, self)) for _, animation in self._items: animation.start()
def pulse(pix): node = Node(pix) node.pix.setOriginPt() random.seed() sync = random.gauss(450, 50) pulse = QPropertyAnimation(node, b'scale') pulse.setDuration(sync) pulse.setStartValue(node.pix.scale * random.gauss(1.25, .25)) pulse.setEndValue(node.pix.scale * random.gauss(1.25, .25)) pulse.setLoopCount(-1) seq = QSequentialAnimationGroup() seq.addAnimation(pulse) seq.addPause(random.randint(10, 30) * 30) return seq
def menu(self): """ 展示动画效果 :return: """ animation_group = QSequentialAnimationGroup(self.widget) for idx, target in enumerate(self.animation_targets): animation = QPropertyAnimation() animation.setTargetObject(target) animation.setPropertyName(b"pos") animation.setStartValue(self.menu_btn.pos()) animation.setEndValue(self.animation_targets_pos[idx]) animation.setDuration(self.duration) animation.setEasingCurve(QEasingCurve.InOutBounce) animation_group.addAnimation(animation) animation_group.setDirection(self.checked) animation_group.start(QAbstractAnimation.DeleteWhenStopped)
def set_fadeout(self, wait_for_sec=7): opc = QGraphicsOpacityEffect(self) self.opc = opc self.setGraphicsEffect(opc) cue = QSequentialAnimationGroup() self.cue = cue cue.addPause(wait_for_sec * 1000) # Fade-out anim = QPropertyAnimation(opc, b"opacity") self.anim = anim anim.setDuration(3000) anim.setStartValue(1) anim.setEndValue(0) anim.setEasingCurve(QEasingCurve.InExpo) cue.addAnimation(anim) cue.finished.connect(self.deleteLater) cue.start(QAbstractAnimation.DeleteWhenStopped)
def __init__(self, parent=None, bar_color=Qt.gray, checked_color="#00B0FF", handle_color=Qt.white, pulse_unchecked_color="#44999999", pulse_checked_color="#4400B0EE" ): super().__init__(parent) # Save our properties on the object via self, so we can access them later # in the paintEvent. self._bar_brush = QBrush(bar_color) self._bar_checked_brush = QBrush(QColor(checked_color).lighter()) self._handle_brush = QBrush(handle_color) self._handle_checked_brush = QBrush(QColor(checked_color)) self._pulse_unchecked_animation = QBrush(QColor(pulse_unchecked_color)) self._pulse_checked_animation = QBrush(QColor(pulse_checked_color)) # Setup the rest of the widget. self.setContentsMargins(8, 0, 8, 0) self._handle_position = 0 self._pulse_radius = 0 self.animation = QPropertyAnimation(self, b"handle_position", self) self.animation.setEasingCurve(QEasingCurve.InOutCubic) self.animation.setDuration(200) # time in ms self.pulse_anim = QPropertyAnimation(self, b"pulse_radius", self) self.pulse_anim.setDuration(350) # time in ms self.pulse_anim.setStartValue(10) self.pulse_anim.setEndValue(20) self.animations_group = QSequentialAnimationGroup() self.animations_group.addAnimation(self.animation) self.animations_group.addAnimation(self.pulse_anim) self.stateChanged.connect(self.setup_animation)
def stage(pix, which): node = Node(pix) pos = node.pix.pos() node.pix.setOriginPt() x = int(pos.x()) ViewW = common["ViewW"] left = x + node.pix.width * 3 right = ViewW + node.pix.width * 3 if which.endswith('Left'): stage1, stage2 = stageLeft(node, pos, left, right) else: stage1, stage2 = stageRight(node, pos, left, right) stage = QSequentialAnimationGroup() stage.addAnimation(stage1) stage.addAnimation(stage2) stage.setLoopCount(-1) return stage
def smooth_move(self, number): if self.is_in_base(): deley = 500 self.parent().anim = QPropertyAnimation(self, b"geometry") self.parent().anim.setDuration(deley) self.parent().anim.setEndValue(self.__positions[0].geometry()) self.parent().anim.start() else: deley = 250 * number pic_index = [pos.geometry() for pos in self.__positions].index(self.geometry()) self.parent().anim_grp = QSequentialAnimationGroup() for i in range(number): self.parent().anim = QPropertyAnimation(self, b"geometry") self.parent().anim.setDuration(250) self.parent().anim.setStartValue( self.__positions[pic_index + i].geometry()) self.parent().anim.setEndValue(self.__positions[pic_index + i + 1].geometry()) self.parent().anim_grp.addAnimation(self.parent().anim) self.parent().anim_grp.start() return deley + 100
def config_animation(self, duration): """Start a fading animation for this label Arguments: duration {int} -- Duration in milliseconds of a complete fadein-fadeout cycle """ self.effect = QGraphicsOpacityEffect() self.setGraphicsEffect(self.effect) self.fadeout = QPropertyAnimation(self.effect, b"opacity") self.fadeout.setDuration(duration) self.fadeout.setStartValue(1) self.fadeout.setEndValue(0) self.fadein = QPropertyAnimation(self.effect, b"opacity") self.fadein.setDuration(duration) self.fadein.setStartValue(0) self.fadein.setEndValue(1) self.group_animation = QSequentialAnimationGroup() self.group_animation.addAnimation(self.fadein) self.group_animation.addAnimation(self.fadeout) self.group_animation.setLoopCount(-1)
def start_animation(self, duration): """Start a fadein-fadeout animation Arguments: duration {int} -- Duration of millisecondns of each fadein-fadeout cycle of the animation. """ self.effect = QGraphicsOpacityEffect() self.setGraphicsEffect(self.effect) self.animation1 = QPropertyAnimation(self.effect, b"opacity") self.animation1.setDuration(duration) self.animation1.setStartValue(1) self.animation1.setEndValue(0) self.animation2 = QPropertyAnimation(self.effect, b"opacity") self.animation2.setDuration(duration) self.animation2.setStartValue(0) self.animation2.setEndValue(1) self.ga = QSequentialAnimationGroup() self.ga.addAnimation(self.animation1) self.ga.addAnimation(self.animation2) self.ga.setLoopCount(-1) self.ga.start()
def start_animation(self, duration): """Start the fading animation of the label Arguments: duration {int} -- Duration in milliseconds of a complete fade in-fade out cycle """ self.effect = QGraphicsOpacityEffect() self.setGraphicsEffect(self.effect) self.animation1 = QPropertyAnimation(self.effect, b"opacity") self.animation1.setDuration(duration) self.animation1.setStartValue(1) self.animation1.setEndValue(0) self.animation2 = QPropertyAnimation(self.effect, b"opacity") self.animation2.setDuration(duration) self.animation2.setStartValue(0) self.animation2.setEndValue(1) self.ga = QSequentialAnimationGroup() self.ga.addAnimation(self.animation1) self.ga.addAnimation(self.animation2) self.ga.setLoopCount(-1) self.ga.start()
def setupUi(self, MainWindow): self.MainWindow = MainWindow self.sequence = QSequentialAnimationGroup() self.sequence.finished.connect(self.animation_finished) self.scene = QGraphicsScene() MainWindow.setObjectName("MainWindow") #MainWindow.setWindowIcon(QtGui.QIcon("icon.png")) MainWindow.resize(self.width, self.height) #qt designer generated code self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.gridLayout = QtWidgets.QGridLayout(self.centralwidget) self.gridLayout.setObjectName("gridLayout") self.graphicsView = QtWidgets.QGraphicsView(self.centralwidget) self.graphicsView.setEnabled(True) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.graphicsView.sizePolicy().hasHeightForWidth()) self.graphicsView.setSizePolicy(sizePolicy) self.graphicsView.setObjectName("graphicsView") self.gridLayout.addWidget(self.graphicsView, 3, 1, 1, 1) self.gridLayout_2 = QtWidgets.QGridLayout() self.gridLayout_2.setObjectName("gridLayout_2") self.pushButton_1 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_1.setObjectName("pushButton_1") self.gridLayout_2.addWidget(self.pushButton_1, 3, 0, 1, 1) self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_2.setObjectName("pushButton_2") self.gridLayout_2.addWidget(self.pushButton_2, 5, 0, 1, 1) self.pushButton_4 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_4.setObjectName("pushButton_4") self.gridLayout_2.addWidget(self.pushButton_4, 9, 0, 1, 1) self.lineEdit_3 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_3.setObjectName("lineEdit_3") self.gridLayout_2.addWidget(self.lineEdit_3, 6, 0, 1, 1) self.pushButton_0 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_0.setObjectName("pushButton_0") self.gridLayout_2.addWidget(self.pushButton_0, 1, 0, 1, 1) self.lineEdit_1 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_1.setObjectName("lineEdit_1") self.gridLayout_2.addWidget(self.lineEdit_1, 2, 0, 1, 1) self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_3.setObjectName("pushButton_3") self.gridLayout_2.addWidget(self.pushButton_3, 7, 0, 1, 1) self.pushButton_6 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_6.setObjectName("pushButton_6") self.gridLayout_2.addWidget(self.pushButton_6, 14, 0, 1, 1) self.pushButton_7 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_7.setObjectName("pushButton_7") self.gridLayout_2.addWidget(self.pushButton_7, 19, 0, 1, 1) self.lineEdit_4 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_4.setObjectName("lineEdit_4") self.gridLayout_2.addWidget(self.lineEdit_4, 8, 0, 1, 1) self.lineEdit_0 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_0.setObjectName("lineEdit_0") self.gridLayout_2.addWidget(self.lineEdit_0, 0, 0, 1, 1) self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_2.setObjectName("lineEdit_2") self.gridLayout_2.addWidget(self.lineEdit_2, 4, 0, 1, 1) self.pushButton_5 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_5.setObjectName("pushButton_5") self.gridLayout_2.addWidget(self.pushButton_5, 11, 0, 1, 1) self.lineEdit_7 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_7.setObjectName("lineEdit_7") self.gridLayout_2.addWidget(self.lineEdit_7, 17, 0, 1, 1) self.lineEdit_5 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_5.setObjectName("lineEdit_5") self.gridLayout_2.addWidget(self.lineEdit_5, 10, 0, 1, 1) self.lineEdit_6 = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_6.setObjectName("lineEdit_6") self.gridLayout_2.addWidget(self.lineEdit_6, 12, 0, 1, 1) self.gridLayout.addLayout(self.gridLayout_2, 3, 0, 1, 1) MainWindow.setCentralWidget(self.centralwidget) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) #end of eq designer generated code self.lineEdits = [] self.lineEdits.append(self.lineEdit_0) self.lineEdits.append(self.lineEdit_1) self.lineEdits.append(self.lineEdit_2) self.lineEdits.append(self.lineEdit_3) self.lineEdits.append(self.lineEdit_4) self.lineEdits.append(self.lineEdit_5) self.lineEdits.append(self.lineEdit_6) self.lineEdits.append(self.lineEdit_7) self.pushButtons = [] self.pushButtons.append(self.pushButton_0) self.pushButtons.append(self.pushButton_1) self.pushButtons.append(self.pushButton_2) self.pushButtons.append(self.pushButton_3) self.pushButtons.append(self.pushButton_4) self.pushButtons.append(self.pushButton_5) self.pushButtons.append(self.pushButton_6) self.pushButtons.append(self.pushButton_7) self.graphicsView.setScene(self.scene) self.graphicsView.setSceneRect(0, 0, 0, 0) self.graphicsView.setRenderHints(QPainter.Antialiasing) # self.graphicsView.fitInView(self.scene.sceneRect(), Qt.KeepAspectRatio) self.graphicsView.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers))) self.graphicsView.scale(self.zoom, -self.zoom) self.graphicsView.setDragMode(1)
def __init__(self, size, parent=None): super(PadNavigator, self).__init__(parent) self.form = Ui_Form() splash = SplashItem() splash.setZValue(1) pad = FlippablePad(size) flipRotation = QGraphicsRotation(pad) xRotation = QGraphicsRotation(pad) yRotation = QGraphicsRotation(pad) flipRotation.setAxis(Qt.YAxis) xRotation.setAxis(Qt.YAxis) yRotation.setAxis(Qt.XAxis) pad.setTransformations([flipRotation, xRotation, yRotation]) backItem = QGraphicsProxyWidget(pad) widget = QWidget() self.form.setupUi(widget) self.form.hostName.setFocus() backItem.setWidget(widget) backItem.setVisible(False) backItem.setFocus() backItem.setCacheMode(QGraphicsItem.ItemCoordinateCache) r = backItem.rect() backItem.setTransform(QTransform().rotate(180, Qt.YAxis).translate( -r.width() / 2, -r.height() / 2)) selectionItem = RoundRectItem(QRectF(-60, -60, 120, 120), QColor(Qt.gray), pad) selectionItem.setZValue(0.5) smoothSplashMove = QPropertyAnimation(splash) smoothSplashOpacity = QPropertyAnimation(splash) smoothSplashMove.setEasingCurve(QEasingCurve.InQuad) smoothSplashMove.setDuration(250) smoothSplashOpacity.setDuration(250) smoothXSelection = QPropertyAnimation(selectionItem) smoothYSelection = QPropertyAnimation(selectionItem) smoothXRotation = QPropertyAnimation(xRotation) smoothYRotation = QPropertyAnimation(yRotation) smoothXSelection.setDuration(125) smoothYSelection.setDuration(125) smoothXRotation.setDuration(125) smoothYRotation.setDuration(125) smoothXSelection.setEasingCurve(QEasingCurve.InOutQuad) smoothYSelection.setEasingCurve(QEasingCurve.InOutQuad) smoothXRotation.setEasingCurve(QEasingCurve.InOutQuad) smoothYRotation.setEasingCurve(QEasingCurve.InOutQuad) smoothFlipRotation = QPropertyAnimation(flipRotation) smoothFlipScale = QPropertyAnimation(pad) smoothFlipXRotation = QPropertyAnimation(xRotation) smoothFlipYRotation = QPropertyAnimation(yRotation) flipAnimation = QParallelAnimationGroup(self) smoothFlipScale.setDuration(500) smoothFlipRotation.setDuration(500) smoothFlipXRotation.setDuration(500) smoothFlipYRotation.setDuration(500) smoothFlipScale.setEasingCurve(QEasingCurve.InOutQuad) smoothFlipRotation.setEasingCurve(QEasingCurve.InOutQuad) smoothFlipXRotation.setEasingCurve(QEasingCurve.InOutQuad) smoothFlipYRotation.setEasingCurve(QEasingCurve.InOutQuad) smoothFlipScale.setKeyValueAt(0, 1.0) smoothFlipScale.setKeyValueAt(0.5, 0.7) smoothFlipScale.setKeyValueAt(1, 1.0) flipAnimation.addAnimation(smoothFlipRotation) flipAnimation.addAnimation(smoothFlipScale) flipAnimation.addAnimation(smoothFlipXRotation) flipAnimation.addAnimation(smoothFlipYRotation) setVariablesSequence = QSequentialAnimationGroup() setFillAnimation = QPropertyAnimation(pad) setBackItemVisibleAnimation = QPropertyAnimation(backItem) setSelectionItemVisibleAnimation = QPropertyAnimation(selectionItem) setFillAnimation.setDuration(0) setBackItemVisibleAnimation.setDuration(0) setSelectionItemVisibleAnimation.setDuration(0) setVariablesSequence.addPause(250) setVariablesSequence.addAnimation(setBackItemVisibleAnimation) setVariablesSequence.addAnimation(setSelectionItemVisibleAnimation) setVariablesSequence.addAnimation(setFillAnimation) flipAnimation.addAnimation(setVariablesSequence) stateMachine = QStateMachine(self) splashState = QState(stateMachine) frontState = QState(stateMachine) historyState = QHistoryState(frontState) backState = QState(stateMachine) frontState.assignProperty(pad, "fill", False) frontState.assignProperty(splash, "opacity", 0.0) frontState.assignProperty(backItem, "visible", False) frontState.assignProperty(flipRotation, "angle", 0.0) frontState.assignProperty(selectionItem, "visible", True) backState.assignProperty(pad, "fill", True) backState.assignProperty(backItem, "visible", True) backState.assignProperty(xRotation, "angle", 0.0) backState.assignProperty(yRotation, "angle", 0.0) backState.assignProperty(flipRotation, "angle", 180.0) backState.assignProperty(selectionItem, "visible", False) stateMachine.addDefaultAnimation(smoothXRotation) stateMachine.addDefaultAnimation(smoothYRotation) stateMachine.addDefaultAnimation(smoothXSelection) stateMachine.addDefaultAnimation(smoothYSelection) stateMachine.setInitialState(splashState) anyKeyTransition = QEventTransition(self, QEvent.KeyPress, splashState) anyKeyTransition.setTargetState(frontState) anyKeyTransition.addAnimation(smoothSplashMove) anyKeyTransition.addAnimation(smoothSplashOpacity) enterTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Enter, backState) returnTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Return, backState) backEnterTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Enter, frontState) backReturnTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Return, frontState) enterTransition.setTargetState(historyState) returnTransition.setTargetState(historyState) backEnterTransition.setTargetState(backState) backReturnTransition.setTargetState(backState) enterTransition.addAnimation(flipAnimation) returnTransition.addAnimation(flipAnimation) backEnterTransition.addAnimation(flipAnimation) backReturnTransition.addAnimation(flipAnimation) columns = size.width() rows = size.height() stateGrid = [] for y in range(rows): stateGrid.append([QState(frontState) for _ in range(columns)]) frontState.setInitialState(stateGrid[0][0]) selectionItem.setPos(pad.iconAt(0, 0).pos()) for y in range(rows): for x in range(columns): state = stateGrid[y][x] rightTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Right, state) leftTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Left, state) downTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Down, state) upTransition = QKeyEventTransition(self, QEvent.KeyPress, Qt.Key_Up, state) rightTransition.setTargetState(stateGrid[y][(x + 1) % columns]) leftTransition.setTargetState( stateGrid[y][((x - 1) + columns) % columns]) downTransition.setTargetState(stateGrid[(y + 1) % rows][x]) upTransition.setTargetState(stateGrid[((y - 1) + rows) % rows][x]) icon = pad.iconAt(x, y) state.assignProperty(xRotation, "angle", -icon.x() / 6.0) state.assignProperty(yRotation, "angle", icon.y() / 6.0) state.assignProperty(selectionItem, "x", icon.x()) state.assignProperty(selectionItem, "y", icon.y()) frontState.assignProperty(icon, "visible", True) backState.assignProperty(icon, "visible", False) setIconVisibleAnimation = QPropertyAnimation(icon) setIconVisibleAnimation.setDuration(0) setVariablesSequence.addAnimation(setIconVisibleAnimation) scene = QGraphicsScene(self) scene.setBackgroundBrush( QBrush(QPixmap(":/images/blue_angle_swirl.jpg"))) scene.setItemIndexMethod(QGraphicsScene.NoIndex) scene.addItem(pad) scene.setSceneRect(scene.itemsBoundingRect()) self.setScene(scene) sbr = splash.boundingRect() splash.setPos(-sbr.width() / 2, scene.sceneRect().top() - 2) frontState.assignProperty(splash, "y", splash.y() - 100.0) scene.addItem(splash) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setMinimumSize(50, 50) self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate) self.setCacheMode(QGraphicsView.CacheBackground) self.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform | QPainter.TextAntialiasing) if QGLFormat.hasOpenGL(): self.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers))) stateMachine.start()
state3.assignProperty(p2, 'pos', QPointF(0, 5 + 64 + 5)) state3.assignProperty(p3, 'pos', QPointF(5, 5 + (64 + 5) + 64)) state3.assignProperty(p4, 'pos', QPointF(5 + 64 + 5, 5)) state3.assignProperty(p5, 'pos', QPointF(5 + 64 + 5, 5 + 64 + 5)) state3.assignProperty(p6, 'pos', QPointF(5 + 64 + 5, 5 + (64 + 5) + 64)) state3.assignProperty(widget, 'geometry', QRectF(138, 5, 400 - 138, 200)) state3.assignProperty(box, 'geometry', QRect(5, 205, 400, 90)) state3.assignProperty(p1, 'opacity', 1.0) state3.assignProperty(p2, 'opacity', 1.0) state3.assignProperty(p3, 'opacity', 1.0) state3.assignProperty(p4, 'opacity', 1.0) state3.assignProperty(p5, 'opacity', 1.0) state3.assignProperty(p6, 'opacity', 1.0) t1 = state1.addTransition(button.clicked, state2) animation1SubGroup = QSequentialAnimationGroup() animation1SubGroup.addPause(250) animation1SubGroup.addAnimation( QPropertyAnimation(box, b'geometry', state1)) t1.addAnimation(animation1SubGroup) t1.addAnimation(QPropertyAnimation(widget, b'geometry', state1)) t1.addAnimation(QPropertyAnimation(p1, b'pos', state1)) t1.addAnimation(QPropertyAnimation(p2, b'pos', state1)) t1.addAnimation(QPropertyAnimation(p3, b'pos', state1)) t1.addAnimation(QPropertyAnimation(p4, b'pos', state1)) t1.addAnimation(QPropertyAnimation(p5, b'pos', state1)) t1.addAnimation(QPropertyAnimation(p6, b'pos', state1)) t1.addAnimation(QPropertyAnimation(p1, b'rotation', state1)) t1.addAnimation(QPropertyAnimation(p2, b'rotation', state1)) t1.addAnimation(QPropertyAnimation(p3, b'rotation', state1)) t1.addAnimation(QPropertyAnimation(p4, b'rotation', state1))