Skip to content

Commit a102b92

Browse files
committed
Animation
1 parent a49a423 commit a102b92

36 files changed

+24
-391
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

动画/多页面切换动画/UiImageSlider.ui Animation/Data/UiImageSlider.ui

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
<customwidget>
130130
<class>SlidingStackedWidget</class>
131131
<extends>QStackedWidget</extends>
132-
<header location="global">SlidingStackedWidget</header>
132+
<header location="global">Lib.SlidingStackedWidget</header>
133133
<container>1</container>
134134
</customwidget>
135135
</customwidgets>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

动画/窗口淡入淡出.py Animation/FadeInOut.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# author: Irony
99
# site: https://pyqt5.com, https://github.com/892768447
1010
# email: 892768447@qq.com
11-
# file: 动画特效.淡入淡出
11+
# file: FadeInOut
1212
# description:
1313
__Author__ = """By: Irony
1414
QQ: 892768447

动画/右键菜单动画.py Animation/MenuAnimation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@author: Irony
77
@site: https://pyqt5.com, https://github.com/892768447
88
@email: 892768447@qq.com
9-
@file: 动画特效.右键菜单动画
9+
@file: MenuAnimation
1010
@description:
1111
"""
1212
from PyQt5.QtCore import QPropertyAnimation, QEasingCurve, QRect

动画/多页面切换动画/图片轮播动画.py Animation/PageSwitching.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
author: Irony
77
site: https://pyqt5.com , https://github.com/892768447
88
email: 892768447@qq.com
9-
file:
9+
file: PageSwitching
1010
description:
1111
"""
1212
import os
@@ -15,7 +15,7 @@
1515
from PyQt5.QtGui import QPixmap
1616
from PyQt5.QtWidgets import QWidget, QLabel
1717

18-
from UiImageSlider import Ui_Form # @UnresolvedImport
18+
from Lib.UiImageSlider import Ui_Form # @UnresolvedImport
1919

2020

2121
__Author__ = """By: Irony
@@ -48,10 +48,10 @@ def __init__(self, *args, **kwargs):
4848
self.pushButtonStop.clicked.connect(self.autoStop)
4949

5050
# 添加图片页面
51-
for name in os.listdir('Images'):
51+
for name in os.listdir('Data/Images'):
5252
label = QLabel(self.stackedWidget)
5353
label.setScaledContents(True)
54-
label.setPixmap(QPixmap('Images/' + name))
54+
label.setPixmap(QPixmap('Data/Images/' + name))
5555
self.stackedWidget.addWidget(label)
5656

5757
def autoStart(self):

Animation/README.en.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Animation

动画/README.md Animation/README.md

+13-41
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# 动画特效
1+
# Animation
22

3-
使用QPropertyAnimation属性类动画(支持的属性有限)
4-
5-
## [1、窗口淡入淡出](窗口淡入淡出.py)
3+
# 1、窗口淡入淡出
4+
[运行 FadeInOut.py](FadeInOut.py)
65

76
1. 使用`QPropertyAnimation`对窗口的`windowOpacity`透明度属性进行修改
87
1. 窗口启动时开启透明度0-->1的动画
@@ -12,46 +11,18 @@
1211
1. 停止就动画
1312
1. 绑定动画完成后`finished`信号连接到`close`关闭窗口函数
1413

15-
![截图](ScreenShot/窗口淡入淡出.gif)
14+
![FadeInOut](ScreenShot/FadeInOut.gif)
1615

17-
## [2、右键菜单动画](右键菜单动画.py)
16+
# 2、右键菜单动画
17+
[运行 MenuAnimation](MenuAnimation.py)
1818

1919
1. 使用`QPropertyAnimation`对菜单控件的`geometry`属性进行修改
2020
1. 当菜单事件`contextMenuEvent`触发时调用动画启动,同时显示菜单
2121

22-
![截图](ScreenShot/右键菜单动画.gif)
23-
24-
## [3、按钮放大缩小动画](按钮放大缩小动画.py)
25-
26-
1. 使用`QPropertyAnimation`对按钮的`geometry`属性进行修改
27-
1. 针对按钮在布局中或者没有在布局中两种情况,需要对主窗口的`showEvent``resizeEvent`两个事件进行重写,从而达到更新按钮的最新`geometry`
28-
1. 主动调用按钮的`updatePos`函数来更新`geometry`
29-
30-
比如:
31-
32-
```python
33-
def showEvent(self, event):
34-
super(TestWindow, self).showEvent(event)
35-
# 更新按钮的位置
36-
self.button1.updatePos()
37-
# 针对不在控件中的按钮
38-
self.button2.move(self.width() - self.button2.width() - 15,
39-
self.height() - self.button2.height() - 10)
40-
self.button2.updatePos()
41-
42-
def resizeEvent(self, event):
43-
super(TestWindow, self).resizeEvent(event)
44-
# 更新按钮的位置
45-
self.button1.updatePos()
46-
# 针对不在控件中的按钮
47-
self.button2.move(self.width() - self.button2.width() - 15,
48-
self.height() - self.button2.height() - 10)
49-
self.button2.updatePos()
50-
```
51-
52-
![截图](ScreenShot/按钮放大缩小动画.gif)
22+
![MenuAnimation](ScreenShot/MenuAnimation.gif)
5323

54-
## [4、点阵特效](点阵特效.py)
24+
## 3、点阵特效
25+
[运行 RlatticeEffect.py](RlatticeEffect.py)
5526

5627
1. emmm,我也不知道这个动画叫啥名字,反正就是仿照网页做的
5728
1. 参考js源码,大概的原理就是:
@@ -123,9 +94,10 @@ def findClose(points):
12394
p1.closest = closest
12495
```
12596

126-
![截图](ScreenShot/点阵特效.gif)
97+
![RlatticeEffect](ScreenShot/RlatticeEffect.gif)
12798

128-
## [5、图片轮播动画](多页面切换动画/图片轮播动画.py)
99+
## 5、页面切换/图片轮播动画
100+
[运行 PageSwitching.py](PageSwitching.py)
129101

130102
1. 使用`QPropertyAnimation``QStackedWidget`中的子控件进行pos位移操作实现动画切换特效
131103
1. 主要代码参考http://qt.shoutwiki.com/wiki/Extending_QStackedWidget_for_sliding_page_animations_in_Qt
@@ -138,4 +110,4 @@ def findClose(points):
138110
1. `setCurrentIndex` 切换到指定页
139111
1. `autoStart(msec)` 轮播模式, 默认是3000毫秒
140112

141-
![截图](ScreenShot/图片轮播动画.gif)
113+
![PageSwitching](ScreenShot/PageSwitching.gif)

动画/点阵特效/点阵特效.py Animation/RlatticeEffect.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@author: Irony
77
@site: https://pyqt5.com, https://github.com/892768447
88
@email: 892768447@qq.com
9-
@file:
9+
@file: RlatticeEffect
1010
@description:
1111
"""
1212
from random import random
@@ -26,7 +26,7 @@
2626

2727

2828
try:
29-
import pointtool # @UnusedImport @UnresolvedImport
29+
from Lib import pointtool # @UnusedImport @UnresolvedImport
3030
getDistance = pointtool.getDistance
3131
findClose = pointtool.findClose
3232
except:
File renamed without changes.
File renamed without changes.

动画/按钮放大缩小动画.py Test/ButtomZoom.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@author: Irony
77
@site: http://pyqt5.com https://github.com/892768447
88
@email: 892768447@qq.com
9-
@file:
9+
@file: ButtomZoom
1010
@description:
1111
"""
1212
from PyQt5.QtCore import QPropertyAnimation, QRect
File renamed without changes.

0 commit comments

Comments
 (0)