Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
4b25ad5b
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看板
提交
4b25ad5b
编写于
3月 15, 2023
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加图标抽象类 `FluentIconBase`
上级
8a25718b
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
86 addition
and
78 deletion
+86
-78
qfluentwidgets/__init__.py
qfluentwidgets/__init__.py
+1
-1
qfluentwidgets/common/__init__.py
qfluentwidgets/common/__init__.py
+1
-1
qfluentwidgets/common/icon.py
qfluentwidgets/common/icon.py
+54
-45
qfluentwidgets/components/navigation/navigation_interface.py
qfluentwidgets/components/navigation/navigation_interface.py
+3
-3
qfluentwidgets/components/navigation/navigation_panel.py
qfluentwidgets/components/navigation/navigation_panel.py
+4
-4
qfluentwidgets/components/navigation/navigation_widget.py
qfluentwidgets/components/navigation/navigation_widget.py
+1
-1
qfluentwidgets/components/settings/options_setting_card.py
qfluentwidgets/components/settings/options_setting_card.py
+3
-3
qfluentwidgets/components/settings/setting_card.py
qfluentwidgets/components/settings/setting_card.py
+15
-15
qfluentwidgets/components/widgets/icon_widget.py
qfluentwidgets/components/widgets/icon_widget.py
+3
-4
setup.py
setup.py
+1
-1
未找到文件。
qfluentwidgets/__init__.py
浏览文件 @
4b25ad5b
...
...
@@ -12,7 +12,7 @@ Examples are available at https://github.com/zhiyiYo/PyQt-Fluent-Widgets/tree/ma
:license: MIT, see LICENSE for more details.
"""
__version__
=
"0.3.
0
"
__version__
=
"0.3.
1
"
from
.components
import
*
from
.common
import
*
...
...
qfluentwidgets/common/__init__.py
浏览文件 @
4b25ad5b
from
.config
import
*
from
.auto_wrap
import
TextWrap
from
.icon
import
Icon
,
getIconColor
,
drawSvgIcon
,
FluentIcon
,
drawIcon
from
.icon
import
Icon
,
getIconColor
,
drawSvgIcon
,
FluentIcon
,
drawIcon
,
FluentIconBase
from
.style_sheet
import
setStyleSheet
,
getStyleSheet
,
setTheme
from
.smooth_scroll
import
SmoothScroll
,
SmoothMode
\ No newline at end of file
qfluentwidgets/common/icon.py
浏览文件 @
4b25ad5b
...
...
@@ -70,12 +70,12 @@ def drawSvgIcon(iconPath, painter, rect):
renderer
.
render
(
painter
,
QRectF
(
rect
))
def
drawIcon
(
icon
,
painter
:
QPainter
,
rect
):
def
drawIcon
(
icon
,
painter
,
rect
):
""" draw icon
Parameters
----------
icon:
`str` | `QIcon` | `FluentIcon`
icon:
str | QIcon | FluentIconBaseBase
the icon to be drawn
painter: QPainter
...
...
@@ -84,7 +84,7 @@ def drawIcon(icon, painter:QPainter, rect):
rect: QRect | QRectF
the rect to render icon
"""
if
isinstance
(
icon
,
FluentIcon
):
if
isinstance
(
icon
,
FluentIcon
Base
):
icon
.
render
(
painter
,
rect
)
else
:
icon
=
QIcon
(
icon
)
...
...
@@ -92,7 +92,57 @@ def drawIcon(icon, painter:QPainter, rect):
painter
.
drawPixmap
(
rect
,
image
)
class
FluentIcon
(
Enum
):
class
FluentIconBase
:
""" Fluent icon base class """
def
path
(
self
,
theme
=
Theme
.
AUTO
):
""" get the path of icon
Parameters
----------
theme: Theme
the theme of icon
* `Theme.Light`: black icon
* `Theme.DARK`: white icon
* `Theme.AUTO`: icon color depends on `config.theme`
"""
raise
NotImplementedError
def
icon
(
self
,
theme
=
Theme
.
AUTO
):
""" create an fluent icon
Parameters
----------
theme: Theme
the theme of icon
* `Theme.Light`: black icon
* `Theme.DARK`: white icon
* `Theme.AUTO`: icon color depends on `config.theme`
"""
return
QIcon
(
self
.
path
(
theme
))
def
render
(
self
,
painter
,
rect
,
theme
=
Theme
.
AUTO
):
""" draw svg icon
Parameters
----------
painter: QPainter
painter
rect: QRect | QRectF
the rect to render icon
theme: Theme
the theme of icon
* `Theme.Light`: black icon
* `Theme.DARK`: white icon
* `Theme.AUTO`: icon color depends on `config.theme`
"""
drawSvgIcon
(
self
.
path
(
theme
),
painter
,
rect
)
class
FluentIcon
(
FluentIconBase
,
Enum
):
""" Fluent icon """
WEB
=
"Web"
...
...
@@ -134,16 +184,6 @@ class FluentIcon(Enum):
FLUORESCENT_PEN
=
"FluorescentPen"
def
path
(
self
,
theme
=
Theme
.
AUTO
):
""" get the path of icon
Parameters
----------
theme: Theme
the theme of icon
* `Theme.Light`: black icon
* `Theme.DARK`: white icon
* `Theme.AUTO`: icon color depends on `config.theme`
"""
if
theme
==
Theme
.
AUTO
:
c
=
getIconColor
()
else
:
...
...
@@ -151,34 +191,3 @@ class FluentIcon(Enum):
return
f
':/qfluentwidgets/images/icons/
{
self
.
value
}
_
{
c
}
.svg'
def
icon
(
self
,
theme
=
Theme
.
AUTO
):
""" create an fluent icon
Parameters
----------
theme: Theme
the theme of icon
* `Theme.Light`: black icon
* `Theme.DARK`: white icon
* `Theme.AUTO`: icon color depends on `config.theme`
"""
return
QIcon
(
self
.
path
(
theme
))
def
render
(
self
,
painter
,
rect
,
theme
=
Theme
.
AUTO
):
""" draw svg icon
Parameters
----------
painter: QPainter
painter
rect: QRect | QRectF
the rect to render icon
theme: Theme
the theme of icon
* `Theme.Light`: black icon
* `Theme.DARK`: white icon
* `Theme.AUTO`: icon color depends on `config.theme`
"""
drawSvgIcon
(
self
.
path
(
theme
),
painter
,
rect
)
\ No newline at end of file
qfluentwidgets/components/navigation/navigation_interface.py
浏览文件 @
4b25ad5b
...
...
@@ -7,7 +7,7 @@ from PyQt5.QtWidgets import QWidget
from
.navigation_panel
import
NavigationPanel
,
NavigationItemPostion
,
NavigationWidget
,
NavigationDisplayMode
from
...common.style_sheet
import
setStyleSheet
from
...common.icon
import
FluentIcon
from
...common.icon
import
FluentIcon
Base
class
NavigationInterface
(
QWidget
):
...
...
@@ -33,7 +33,7 @@ class NavigationInterface(QWidget):
self
.
setAttribute
(
Qt
.
WA_StyledBackground
)
setStyleSheet
(
self
,
'navigation_interface'
)
def
addItem
(
self
,
routeKey
:
str
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
],
text
:
str
,
onClick
,
selectable
=
True
,
position
=
NavigationItemPostion
.
TOP
):
def
addItem
(
self
,
routeKey
:
str
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
Base
],
text
:
str
,
onClick
,
selectable
=
True
,
position
=
NavigationItemPostion
.
TOP
):
""" add navigation item
Parameters
...
...
@@ -41,7 +41,7 @@ class NavigationInterface(QWidget):
routKey: str
the unique name of item
icon: str | QIcon | FluentIcon
icon: str | QIcon | FluentIcon
Base
the icon of navigation item
text: str
...
...
qfluentwidgets/components/navigation/navigation_panel.py
浏览文件 @
4b25ad5b
...
...
@@ -9,7 +9,7 @@ from PyQt5.QtWidgets import QWidget, QVBoxLayout, QFrame, QApplication
from
.navigation_widget
import
NavigationButton
,
MenuButton
,
NavigationWidget
,
NavigationSeparator
from
..widgets.scroll_area
import
ScrollArea
from
...common.style_sheet
import
setStyleSheet
,
getStyleSheet
from
...common.icon
import
FluentIcon
from
...common.icon
import
FluentIcon
Base
class
NavigationDisplayMode
(
Enum
):
...
...
@@ -96,7 +96,7 @@ class NavigationPanel(QFrame):
self
.
topLayout
.
addWidget
(
self
.
menuButton
,
0
,
Qt
.
AlignTop
)
def
addItem
(
self
,
routeKey
:
str
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
],
text
:
str
,
onClick
,
selectable
=
True
,
position
=
NavigationItemPostion
.
TOP
):
def
addItem
(
self
,
routeKey
:
str
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
Base
],
text
:
str
,
onClick
,
selectable
=
True
,
position
=
NavigationItemPostion
.
TOP
):
""" add navigation item
Parameters
...
...
@@ -104,7 +104,7 @@ class NavigationPanel(QFrame):
routeKey: str
the unique name of item
icon: str | QIcon | FluentIcon
icon: str | QIcon | FluentIcon
Base
the icon of navigation item
text: str
...
...
@@ -289,7 +289,7 @@ class NavigationPanel(QFrame):
elif
self
.
displayMode
==
NavigationDisplayMode
.
COMPACT
:
self
.
setProperty
(
'menu'
,
False
)
self
.
setStyle
(
QApplication
.
style
())
for
item
in
self
.
items
.
values
():
item
.
setCompacted
(
True
)
...
...
qfluentwidgets/components/navigation/navigation_widget.py
浏览文件 @
4b25ad5b
...
...
@@ -77,7 +77,7 @@ class NavigationButton(NavigationWidget):
"""
Parameters
----------
icon: str | QIcon | FluentIcon
icon: str | QIcon | FluentIcon
Base
the icon to be drawn
text: str
...
...
qfluentwidgets/components/settings/options_setting_card.py
浏览文件 @
4b25ad5b
...
...
@@ -5,7 +5,7 @@ from PyQt5.QtGui import QIcon
from
PyQt5.QtWidgets
import
QButtonGroup
,
QLabel
,
QRadioButton
from
...common.config
import
OptionsConfigItem
,
qconfig
from
...common.icon
import
FluentIcon
from
...common.icon
import
FluentIcon
Base
from
.expand_setting_card
import
ExpandSettingCard
...
...
@@ -14,14 +14,14 @@ class OptionsSettingCard(ExpandSettingCard):
optionChanged
=
pyqtSignal
(
OptionsConfigItem
)
def
__init__
(
self
,
configItem
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
],
title
,
content
=
None
,
texts
=
None
,
parent
=
None
):
def
__init__
(
self
,
configItem
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
Base
],
title
,
content
=
None
,
texts
=
None
,
parent
=
None
):
"""
Parameters
----------
configItem: OptionsConfigItem
options config item
icon: str | QIcon | FluentIcon
icon: str | QIcon | FluentIcon
Base
the icon to be drawn
title: str
...
...
qfluentwidgets/components/settings/setting_card.py
浏览文件 @
4b25ad5b
...
...
@@ -13,17 +13,17 @@ from ..widgets.slider import Slider
from
..widgets.icon_widget
import
IconWidget
from
...common.style_sheet
import
setStyleSheet
from
...common.config
import
qconfig
,
isDarkTheme
from
...common.icon
import
FluentIcon
from
...common.icon
import
FluentIcon
Base
class
SettingCard
(
QFrame
):
""" Setting card """
def
__init__
(
self
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
],
title
,
content
=
None
,
parent
=
None
):
def
__init__
(
self
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
Base
],
title
,
content
=
None
,
parent
=
None
):
"""
Parameters
----------
icon: str | QIcon | FluentIcon
icon: str | QIcon | FluentIcon
Base
the icon to be drawn
title: str
...
...
@@ -84,11 +84,11 @@ class SwitchSettingCard(SettingCard):
checkedChanged
=
pyqtSignal
(
bool
)
def
__init__
(
self
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
],
title
,
content
=
None
,
configItem
=
None
,
parent
=
None
):
def
__init__
(
self
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
Base
],
title
,
content
=
None
,
configItem
=
None
,
parent
=
None
):
"""
Parameters
----------
icon: str | QIcon | FluentIcon
icon: str | QIcon | FluentIcon
Base
the icon to be drawn
title: str
...
...
@@ -142,14 +142,14 @@ class RangeSettingCard(SettingCard):
valueChanged
=
pyqtSignal
(
int
)
def
__init__
(
self
,
configItem
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
],
title
,
content
=
None
,
parent
=
None
):
def
__init__
(
self
,
configItem
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
Base
],
title
,
content
=
None
,
parent
=
None
):
"""
Parameters
----------
configItem: RangeConfigItem
configuration item operated by the card
icon: str | QIcon | FluentIcon
icon: str | QIcon | FluentIcon
Base
the icon to be drawn
title: str
...
...
@@ -193,14 +193,14 @@ class PushSettingCard(SettingCard):
clicked
=
pyqtSignal
()
def
__init__
(
self
,
text
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
],
title
,
content
=
None
,
parent
=
None
):
def
__init__
(
self
,
text
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
Base
],
title
,
content
=
None
,
parent
=
None
):
"""
Parameters
----------
text: str
the text of push button
icon: str | QIcon | FluentIcon
icon: str | QIcon | FluentIcon
Base
the icon to be drawn
title: str
...
...
@@ -230,7 +230,7 @@ class PrimaryPushSettingCard(PushSettingCard):
class
HyperlinkCard
(
SettingCard
):
""" Hyperlink card """
def
__init__
(
self
,
url
,
text
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
],
title
,
content
=
None
,
parent
=
None
):
def
__init__
(
self
,
url
,
text
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
Base
],
title
,
content
=
None
,
parent
=
None
):
"""
Parameters
----------
...
...
@@ -240,7 +240,7 @@ class HyperlinkCard(SettingCard):
text: str
text of url
icon: str | QIcon | FluentIcon
icon: str | QIcon | FluentIcon
Base
the icon to be drawn
title: str
...
...
@@ -315,14 +315,14 @@ class ColorSettingCard(SettingCard):
colorChanged
=
pyqtSignal
(
QColor
)
def
__init__
(
self
,
configItem
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
],
title
,
content
=
None
,
parent
=
None
):
def
__init__
(
self
,
configItem
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
Base
],
title
,
content
=
None
,
parent
=
None
):
"""
Parameters
----------
configItem: RangeConfigItem
configuration item operated by the card
icon: str | QIcon | FluentIcon
icon: str | QIcon | FluentIcon
Base
the icon to be drawn
title: str
...
...
@@ -350,14 +350,14 @@ class ColorSettingCard(SettingCard):
class
ComboBoxSettingCard
(
SettingCard
):
""" Setting card with a combo box """
def
__init__
(
self
,
configItem
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
],
title
,
content
=
None
,
texts
=
None
,
parent
=
None
):
def
__init__
(
self
,
configItem
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
Base
],
title
,
content
=
None
,
texts
=
None
,
parent
=
None
):
"""
Parameters
----------
configItem: OptionsConfigItem
configuration item operated by the card
icon: str | QIcon | FluentIcon
icon: str | QIcon | FluentIcon
Base
the icon to be drawn
title: str
...
...
qfluentwidgets/components/widgets/icon_widget.py
浏览文件 @
4b25ad5b
# coding:utf-8
from
typing
import
Union
from
PyQt5.QtCore
import
Qt
,
pyqtSignal
from
PyQt5.QtGui
import
QIcon
,
QPainter
from
PyQt5.QtWidgets
import
QWidget
from
...common.icon
import
FluentIcon
,
drawIcon
from
...common.icon
import
FluentIcon
Base
,
drawIcon
class
IconWidget
(
QWidget
):
""" Icon widget """
def
__init__
(
self
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
],
parent
=
None
):
def
__init__
(
self
,
icon
:
Union
[
str
,
QIcon
,
FluentIcon
Base
],
parent
=
None
):
super
().
__init__
(
parent
=
parent
)
self
.
icon
=
icon
def
paintEvent
(
self
,
e
):
painter
=
QPainter
(
self
)
painter
.
setRenderHints
(
QPainter
.
Antialiasing
|
QPainter
.
SmoothPixmapTransform
)
painter
.
setRenderHints
(
QPainter
.
Antialiasing
|
QPainter
.
SmoothPixmapTransform
)
drawIcon
(
self
.
icon
,
painter
,
self
.
rect
())
setup.py
浏览文件 @
4b25ad5b
...
...
@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools
.
setup
(
name
=
"PyQt-Fluent-Widgets"
,
version
=
"0.3.
0
"
,
version
=
"0.3.
1
"
,
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录