Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
dee562ed
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看板
提交
dee562ed
编写于
7月 11, 2023
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加自定义开关按钮选中图标的功能
上级
c93d5592
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
14 addition
and
16 deletion
+14
-16
qfluentwidgets/__init__.py
qfluentwidgets/__init__.py
+1
-1
qfluentwidgets/common/icon.py
qfluentwidgets/common/icon.py
+2
-4
qfluentwidgets/components/widgets/button.py
qfluentwidgets/components/widgets/button.py
+10
-10
setup.py
setup.py
+1
-1
未找到文件。
qfluentwidgets/__init__.py
浏览文件 @
dee562ed
...
...
@@ -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.0.
1
"
__version__
=
"1.0.
2
"
from
.components
import
*
from
.common
import
*
...
...
qfluentwidgets/common/icon.py
浏览文件 @
dee562ed
...
...
@@ -137,7 +137,7 @@ def writeSvg(iconPath: str, indexes=None, **attributes):
return
dom
.
toString
()
def
drawIcon
(
icon
,
painter
,
rect
,
**
attributes
):
def
drawIcon
(
icon
,
painter
,
rect
,
state
=
QIcon
.
Off
,
**
attributes
):
""" draw icon
Parameters
...
...
@@ -160,9 +160,7 @@ def drawIcon(icon, painter, rect, **attributes):
icon
.
fluentIcon
.
render
(
painter
,
rect
,
**
attributes
)
else
:
icon
=
QIcon
(
icon
)
rect
=
QRectF
(
rect
).
toRect
()
image
=
icon
.
pixmap
(
rect
.
width
(),
rect
.
height
())
painter
.
drawPixmap
(
rect
,
image
)
icon
.
paint
(
painter
,
QRectF
(
rect
).
toRect
(),
Qt
.
AlignCenter
,
state
=
state
)
class
FluentIconBase
:
...
...
qfluentwidgets/components/widgets/button.py
浏览文件 @
dee562ed
...
...
@@ -69,9 +69,9 @@ class PushButton(QPushButton):
self
.
isHover
=
False
self
.
update
()
def
_drawIcon
(
self
,
icon
,
painter
,
rect
):
def
_drawIcon
(
self
,
icon
,
painter
,
rect
,
state
=
QIcon
.
Off
):
""" draw icon """
drawIcon
(
icon
,
painter
,
rect
)
drawIcon
(
icon
,
painter
,
rect
,
state
)
def
paintEvent
(
self
,
e
):
super
().
paintEvent
(
e
)
...
...
@@ -100,7 +100,7 @@ class PushButton(QPushButton):
class
PrimaryPushButton
(
PushButton
):
""" Primary color push button """
def
_drawIcon
(
self
,
icon
,
painter
,
rect
):
def
_drawIcon
(
self
,
icon
,
painter
,
rect
,
state
=
QIcon
.
Off
):
if
isinstance
(
icon
,
FluentIconBase
)
and
self
.
isEnabled
():
# reverse icon color
theme
=
Theme
.
DARK
if
not
isDarkTheme
()
else
Theme
.
LIGHT
...
...
@@ -110,7 +110,7 @@ class PrimaryPushButton(PushButton):
if
isinstance
(
icon
,
FluentIconBase
):
icon
=
icon
.
icon
(
Theme
.
DARK
)
PushButton
.
_drawIcon
(
self
,
icon
,
painter
,
rect
)
PushButton
.
_drawIcon
(
self
,
icon
,
painter
,
rect
,
state
)
class
TransparentPushButton
(
PushButton
):
...
...
@@ -128,7 +128,7 @@ class ToggleButton(PushButton):
if
not
self
.
isChecked
():
return
PushButton
.
_drawIcon
(
self
,
icon
,
painter
,
rect
)
PrimaryPushButton
.
_drawIcon
(
self
,
icon
,
painter
,
rect
)
PrimaryPushButton
.
_drawIcon
(
self
,
icon
,
painter
,
rect
,
QIcon
.
On
)
TogglePushButton
=
ToggleButton
...
...
@@ -241,9 +241,9 @@ class ToolButton(QToolButton):
self
.
isHover
=
False
self
.
update
()
def
_drawIcon
(
self
,
icon
,
painter
:
QPainter
,
rect
:
QRectF
):
def
_drawIcon
(
self
,
icon
,
painter
:
QPainter
,
rect
:
QRectF
,
state
=
QIcon
.
Off
):
""" draw icon """
drawIcon
(
icon
,
painter
,
rect
)
drawIcon
(
icon
,
painter
,
rect
,
state
)
def
paintEvent
(
self
,
e
):
super
().
paintEvent
(
e
)
...
...
@@ -272,7 +272,7 @@ class TransparentToolButton(ToolButton):
class
PrimaryToolButton
(
ToolButton
):
""" Primary color tool button """
def
_drawIcon
(
self
,
icon
,
painter
:
QPainter
,
rect
:
QRectF
):
def
_drawIcon
(
self
,
icon
,
painter
:
QPainter
,
rect
:
QRectF
,
state
=
QIcon
.
Off
):
if
isinstance
(
icon
,
FluentIconBase
)
and
self
.
isEnabled
():
# reverse icon color
theme
=
Theme
.
DARK
if
not
isDarkTheme
()
else
Theme
.
LIGHT
...
...
@@ -285,7 +285,7 @@ class PrimaryToolButton(ToolButton):
if
isinstance
(
icon
,
FluentIconBase
):
icon
=
icon
.
icon
(
Theme
.
DARK
)
return
drawIcon
(
icon
,
painter
,
rect
)
return
drawIcon
(
icon
,
painter
,
rect
,
state
)
class
ToggleToolButton
(
ToolButton
):
...
...
@@ -299,7 +299,7 @@ class ToggleToolButton(ToolButton):
if
not
self
.
isChecked
():
return
ToolButton
.
_drawIcon
(
self
,
icon
,
painter
,
rect
)
PrimaryToolButton
.
_drawIcon
(
self
,
icon
,
painter
,
rect
)
PrimaryToolButton
.
_drawIcon
(
self
,
icon
,
painter
,
rect
,
QIcon
.
On
)
class
TransparentToggleToolButton
(
ToggleToolButton
):
...
...
setup.py
浏览文件 @
dee562ed
...
...
@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools
.
setup
(
name
=
"PyQt-Fluent-Widgets"
,
version
=
"1.0.
1
"
,
version
=
"1.0.
2
"
,
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录