Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
bcf509b5
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看板
提交
bcf509b5
编写于
8月 11, 2023
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加头像组件
上级
5f969def
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
111 addition
and
6 deletion
+111
-6
examples/avatar_widget/demo.py
examples/avatar_widget/demo.py
+40
-0
examples/avatar_widget/resource/boqi.gif
examples/avatar_widget/resource/boqi.gif
+0
-0
examples/avatar_widget/resource/shoko.png
examples/avatar_widget/resource/shoko.png
+0
-0
plugins/label_plugin.py
plugins/label_plugin.py
+17
-1
qfluentwidgets/__init__.py
qfluentwidgets/__init__.py
+1
-1
qfluentwidgets/components/widgets/__init__.py
qfluentwidgets/components/widgets/__init__.py
+1
-1
qfluentwidgets/components/widgets/label.py
qfluentwidgets/components/widgets/label.py
+51
-2
setup.py
setup.py
+1
-1
未找到文件。
examples/avatar_widget/demo.py
0 → 100644
浏览文件 @
bcf509b5
# coding:utf-8
import
os
import
sys
from
PyQt5.QtCore
import
Qt
from
PyQt5.QtGui
import
QPixmap
,
QMovie
from
PyQt5.QtWidgets
import
QApplication
,
QWidget
,
QHBoxLayout
from
qfluentwidgets
import
AvatarWidget
class
Demo
(
QWidget
):
def
__init__
(
self
):
super
().
__init__
()
self
.
resize
(
400
,
300
)
self
.
setStyleSheet
(
'Demo {background: white}'
)
self
.
hBoxLayout
=
QHBoxLayout
(
self
)
avatar
=
QPixmap
(
'resource/shoko.png'
)
# avatar = 'resource/boqi.gif'
sizes
=
[
96
,
48
,
32
,
24
]
for
s
in
sizes
:
w
=
AvatarWidget
(
avatar
,
self
)
w
.
setRadius
(
s
/
2
)
self
.
hBoxLayout
.
addWidget
(
w
)
if
__name__
==
'__main__'
:
# enable dpi scale
QApplication
.
setHighDpiScaleFactorRoundingPolicy
(
Qt
.
HighDpiScaleFactorRoundingPolicy
.
PassThrough
)
QApplication
.
setAttribute
(
Qt
.
AA_EnableHighDpiScaling
)
QApplication
.
setAttribute
(
Qt
.
AA_UseHighDpiPixmaps
)
app
=
QApplication
(
sys
.
argv
)
w
=
Demo
()
w
.
show
()
app
.
exec_
()
examples/avatar_widget/resource/boqi.gif
0 → 100644
浏览文件 @
bcf509b5
392.8 KB
examples/avatar_widget/resource/shoko.png
0 → 100644
浏览文件 @
bcf509b5
261.8 KB
plugins/label_plugin.py
浏览文件 @
bcf509b5
...
...
@@ -3,7 +3,7 @@ from PyQt5.QtCore import Qt
from
PyQt5.QtDesigner
import
QPyDesignerCustomWidgetPlugin
from
qfluentwidgets
import
(
BodyLabel
,
CaptionLabel
,
StrongBodyLabel
,
SubtitleLabel
,
TitleLabel
,
LargeTitleLabel
,
DisplayLabel
,
ImageLabel
)
DisplayLabel
,
ImageLabel
,
AvatarWidget
)
from
plugin_base
import
PluginBase
...
...
@@ -128,3 +128,19 @@ class ImageLabelPlugin(LabelPlugin, QPyDesignerCustomWidgetPlugin):
def
domXml
(
self
):
return
f
"""<widget class="
{
self
.
name
()
}
" name="
{
self
.
name
()
}
"></widget>"""
class
AvatarPlugin
(
LabelPlugin
,
QPyDesignerCustomWidgetPlugin
):
""" Avatar plugin """
def
createWidget
(
self
,
parent
):
return
AvatarWidget
(
self
.
icon
().
pixmap
(
72
,
72
),
parent
)
def
icon
(
self
):
return
super
().
icon
(
"PersonPicture"
)
def
name
(
self
):
return
"AvatarWidget"
def
domXml
(
self
):
return
f
"""<widget class="
{
self
.
name
()
}
" name="
{
self
.
name
()
}
"></widget>"""
qfluentwidgets/__init__.py
浏览文件 @
bcf509b5
...
...
@@ -12,7 +12,7 @@ Examples are available at https://github.com/zhiyiYo/PyQt-Fluent-Widgets/tree/ma
:license: GPLv3, see LICENSE for more details.
"""
__version__
=
"1.1.
2
"
__version__
=
"1.1.
3
"
from
.components
import
*
from
.common
import
*
...
...
qfluentwidgets/components/widgets/__init__.py
浏览文件 @
bcf509b5
...
...
@@ -12,7 +12,7 @@ from .command_bar import CommandBar, CommandButton, CommandBarView
from
.line_edit
import
LineEdit
,
TextEdit
,
PlainTextEdit
,
LineEditButton
,
SearchLineEdit
from
.icon_widget
import
IconWidget
from
.label
import
(
PixmapLabel
,
CaptionLabel
,
StrongBodyLabel
,
BodyLabel
,
SubtitleLabel
,
TitleLabel
,
LargeTitleLabel
,
DisplayLabel
,
FluentLabelBase
,
ImageLabel
)
LargeTitleLabel
,
DisplayLabel
,
FluentLabelBase
,
ImageLabel
,
AvatarWidget
)
from
.list_view
import
ListWidget
,
ListView
,
ListItemDelegate
from
.menu
import
(
DWMMenu
,
LineEditMenu
,
RoundMenu
,
MenuAnimationManager
,
MenuAnimationType
,
IndicatorMenuItemDelegate
,
MenuItemDelegate
,
ShortcutMenuItemDelegate
,
CheckableMenu
,
MenuIndicatorType
,
SystemTrayMenu
,
...
...
qfluentwidgets/components/widgets/label.py
浏览文件 @
bcf509b5
# coding:utf-8
from
typing
import
List
,
Union
from
PyQt5.QtCore
import
Qt
,
pyqtProperty
,
QPoint
,
pyqtSignal
,
QSize
from
PyQt5.QtCore
import
Qt
,
pyqtProperty
,
QPoint
,
pyqtSignal
,
QSize
,
QRectF
from
PyQt5.QtGui
import
(
QPixmap
,
QPainter
,
QPalette
,
QColor
,
QFont
,
QImage
,
QPainterPath
,
QImageReader
,
QBrush
,
QMovie
)
from
PyQt5.QtWidgets
import
QLabel
,
QWidget
,
QApplication
...
...
@@ -183,21 +183,28 @@ class ImageLabel(QLabel):
super
().
__init__
(
parent
)
self
.
image
=
QImage
()
self
.
setBorderRadius
(
0
,
0
,
0
,
0
)
self
.
_postInit
()
@
__init__
.
register
def
_
(
self
,
image
:
str
,
parent
=
None
):
self
.
__init__
(
parent
)
self
.
setImage
(
image
)
self
.
_postInit
()
@
__init__
.
register
def
_
(
self
,
image
:
QImage
,
parent
=
None
):
self
.
__init__
(
parent
)
self
.
setImage
(
image
)
self
.
_postInit
()
@
__init__
.
register
def
_
(
self
,
image
:
QPixmap
,
parent
=
None
):
self
.
__init__
(
parent
)
self
.
setImage
(
image
)
self
.
_postInit
()
def
_postInit
(
self
):
pass
def
_onFrameChanged
(
self
,
index
:
int
):
self
.
image
=
self
.
movie
().
currentImage
()
...
...
@@ -343,4 +350,46 @@ class ImageLabel(QLabel):
@
bottomRightRadius
.
setter
def
bottomRightRadius
(
self
,
radius
:
int
):
self
.
setBorderRadius
(
self
.
topLeftRadius
,
self
.
topRightRadius
,
self
.
bottomLeftRadius
,
radius
)
self
.
setBorderRadius
(
self
.
topLeftRadius
,
self
.
topRightRadius
,
self
.
bottomLeftRadius
,
radius
)
class
AvatarWidget
(
ImageLabel
):
""" Avatar widget """
def
_postInit
(
self
):
self
.
setRadius
(
48
)
def
getRadius
(
self
):
return
self
.
_radius
def
setRadius
(
self
,
radius
:
int
):
self
.
_radius
=
radius
self
.
setFixedSize
(
2
*
radius
,
2
*
radius
)
self
.
update
()
def
paintEvent
(
self
,
e
):
if
self
.
isNull
():
return
painter
=
QPainter
(
self
)
painter
.
setRenderHints
(
QPainter
.
Antialiasing
)
# center crop image
image
=
self
.
image
.
scaled
(
self
.
size
()
*
self
.
devicePixelRatioF
(),
Qt
.
KeepAspectRatioByExpanding
,
Qt
.
SmoothTransformation
)
# type: QImage
iw
,
ih
=
image
.
width
(),
image
.
height
()
d
=
self
.
getRadius
()
*
2
*
self
.
devicePixelRatioF
()
x
,
y
=
(
iw
-
d
)
/
2
,
(
ih
-
d
)
/
2
image
=
image
.
copy
(
x
,
y
,
d
,
d
)
# draw image
path
=
QPainterPath
()
path
.
addEllipse
(
QRectF
(
self
.
rect
()))
painter
.
setPen
(
Qt
.
NoPen
)
painter
.
setClipPath
(
path
)
painter
.
drawImage
(
self
.
rect
(),
image
)
radius
=
pyqtProperty
(
int
,
getRadius
,
setRadius
)
\ No newline at end of file
setup.py
浏览文件 @
bcf509b5
...
...
@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools
.
setup
(
name
=
"PyQt-Fluent-Widgets"
,
version
=
"1.1.
2
"
,
version
=
"1.1.
3
"
,
keywords
=
"pyqt fluent widgets"
,
author
=
"zhiyiYo"
,
author_email
=
"shokokawaii@outlook.com"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录