Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
e857bc41
P
PyQt Fluent Widgets
项目概览
k54kdk
/
PyQt Fluent Widgets
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PyQt Fluent Widgets
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
e857bc41
编写于
5月 22, 2022
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加亚克力标签
上级
40f17564
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
165 addition
and
0 deletion
+165
-0
README.md
README.md
+13
-0
screenshot/acrylic_label.png
screenshot/acrylic_label.png
+0
-0
widgets/acrylic_label/acrylic_label.py
widgets/acrylic_label/acrylic_label.py
+138
-0
widgets/acrylic_label/demo.py
widgets/acrylic_label/demo.py
+14
-0
widgets/acrylic_label/resource/noise.png
widgets/acrylic_label/resource/noise.png
+0
-0
widgets/acrylic_label/resource/埃罗芒阿老师.jpg
widgets/acrylic_label/resource/埃罗芒阿老师.jpg
+0
-0
未找到文件。
README.md
浏览文件 @
e857bc41
...
@@ -137,6 +137,19 @@ A collection of commonly used widgets.
...
@@ -137,6 +137,19 @@ A collection of commonly used widgets.
<img
src=
"screenshot/flow_layout.gif"
/>
<img
src=
"screenshot/flow_layout.gif"
/>
</td>
</td>
</tr>
</tr>
<tr>
<td>
Acrylic Label
</td>
<td>
<code>
AcrylicLabel
</code>
</td>
</tr>
<tr>
<td
colspan=
"2"
align=
"center"
>
<img
src=
"screenshot/acrylic_label.png"
/>
</td>
</tr>
<tr>
<tr>
<td>
<td>
Smooth Scroll Area
Smooth Scroll Area
...
...
screenshot/acrylic_label.png
0 → 100644
浏览文件 @
e857bc41
322.4 KB
widgets/acrylic_label/acrylic_label.py
0 → 100644
浏览文件 @
e857bc41
# coding:utf-8
import
numpy
as
np
from
PIL
import
Image
from
PyQt5.QtCore
import
Qt
from
PyQt5.QtGui
import
QBrush
,
QColor
,
QImage
,
QPainter
,
QPixmap
from
PyQt5.QtWidgets
import
QLabel
from
scipy.ndimage.filters
import
gaussian_filter
def
gaussianBlur
(
imagePath
:
str
,
blurRadius
=
18
,
brightFactor
=
1
,
blurPicSize
:
tuple
=
None
)
->
np
.
ndarray
:
if
not
imagePath
.
startswith
(
':'
):
image
=
Image
.
open
(
imagePath
)
else
:
image
=
Image
.
fromqpixmap
(
QPixmap
(
imagePath
))
if
blurPicSize
:
# adjust image size to reduce computation
w
,
h
=
image
.
size
ratio
=
min
(
blurPicSize
[
0
]
/
w
,
blurPicSize
[
1
]
/
h
)
w_
,
h_
=
w
*
ratio
,
h
*
ratio
if
w_
<
w
:
image
=
image
.
resize
((
int
(
w_
),
int
(
h_
)),
Image
.
ANTIALIAS
)
image
=
np
.
array
(
image
)
# handle gray image
if
len
(
image
.
shape
)
==
2
:
image
=
np
.
stack
([
image
,
image
,
image
],
axis
=-
1
)
# blur each channel
for
i
in
range
(
3
):
image
[:,
:,
i
]
=
gaussian_filter
(
image
[:,
:,
i
],
blurRadius
)
*
brightFactor
return
image
class
AcrylicTextureLabel
(
QLabel
):
""" Acrylic texture label """
def
__init__
(
self
,
tintColor
:
QColor
,
luminosityColor
:
QColor
,
noiseOpacity
=
0.03
,
parent
=
None
):
"""
Parameters
----------
tintColor: QColor
RGB tint color
luminosityColor: QColor
luminosity layer color
noiseOpacity: float
noise layer opacity
parent:
parent window
"""
super
().
__init__
(
parent
=
parent
)
self
.
tintColor
=
QColor
(
tintColor
)
self
.
luminosityColor
=
QColor
(
luminosityColor
)
self
.
noiseOpacity
=
noiseOpacity
self
.
noiseImage
=
QImage
(
'resource/noise.png'
)
self
.
setAttribute
(
Qt
.
WA_TranslucentBackground
)
def
setTintColor
(
self
,
color
:
QColor
):
self
.
tintColor
=
color
self
.
update
()
def
paintEvent
(
self
,
e
):
acrylicTexture
=
QImage
(
64
,
64
,
QImage
.
Format_ARGB32_Premultiplied
)
# paint luminosity layer
acrylicTexture
.
fill
(
self
.
luminosityColor
)
# paint tint color
painter
=
QPainter
(
acrylicTexture
)
painter
.
fillRect
(
acrylicTexture
.
rect
(),
self
.
tintColor
)
# paint noise
painter
.
setOpacity
(
self
.
noiseOpacity
)
painter
.
drawImage
(
acrylicTexture
.
rect
(),
self
.
noiseImage
)
acrylicBrush
=
QBrush
(
acrylicTexture
)
painter
=
QPainter
(
self
)
painter
.
fillRect
(
self
.
rect
(),
acrylicBrush
)
class
AcrylicLabel
(
QLabel
):
""" Acrylic label """
def
__init__
(
self
,
blurRadius
:
int
,
tintColor
:
QColor
,
luminosityColor
=
QColor
(
255
,
255
,
255
,
0
),
maxBlurSize
:
tuple
=
None
,
parent
=
None
):
"""
Parameters
----------
blurRadius: int
blur radius
tintColor: QColor
tint color
luminosityColor: QColor
luminosity layer color
maxBlurSize: tuple
maximum image size
parent:
parent window
"""
super
().
__init__
(
parent
=
parent
)
self
.
imagePath
=
''
self
.
blurPixmap
=
QPixmap
()
self
.
blurRadius
=
blurRadius
self
.
maxBlurSize
=
maxBlurSize
self
.
acrylicTextureLabel
=
AcrylicTextureLabel
(
tintColor
,
luminosityColor
,
parent
=
self
)
def
setImage
(
self
,
imagePath
:
str
):
""" set the image to be blurred """
if
imagePath
==
self
.
imagePath
:
return
self
.
imagePath
=
imagePath
image
=
Image
.
fromarray
(
gaussianBlur
(
imagePath
,
self
.
blurRadius
,
0.85
,
self
.
maxBlurSize
))
self
.
blurPixmap
=
image
.
toqpixmap
()
# type:QPixmap
self
.
setPixmap
(
self
.
blurPixmap
)
self
.
adjustSize
()
def
setTintColor
(
self
,
color
:
QColor
):
self
.
acrylicTextureLabel
.
setTintColor
(
color
)
def
resizeEvent
(
self
,
e
):
super
().
resizeEvent
(
e
)
self
.
acrylicTextureLabel
.
resize
(
self
.
size
())
self
.
setPixmap
(
self
.
blurPixmap
.
scaled
(
self
.
size
(),
Qt
.
KeepAspectRatioByExpanding
,
Qt
.
SmoothTransformation
))
widgets/acrylic_label/demo.py
0 → 100644
浏览文件 @
e857bc41
# coding:utf-8
import
sys
from
PyQt5.QtGui
import
QColor
from
PyQt5.QtWidgets
import
QApplication
from
acrylic_label
import
AcrylicLabel
app
=
QApplication
(
sys
.
argv
)
w
=
AcrylicLabel
(
20
,
QColor
(
105
,
114
,
168
,
102
))
w
.
setImage
(
'resource/埃罗芒阿老师.jpg'
)
w
.
show
()
app
.
exec_
()
widgets/acrylic_label/resource/noise.png
0 → 100644
浏览文件 @
e857bc41
265.5 KB
widgets/acrylic_label/resource/埃罗芒阿老师.jpg
0 → 100644
浏览文件 @
e857bc41
72.9 KB
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录