Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
1794ae68
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看板
提交
1794ae68
编写于
4月 22, 2023
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
重载构造函数,适配 QtDesigner
上级
55068da8
变更
13
展开全部
隐藏空白更改
内联
并排
Showing
13 changed file
with
32092 addition
and
31954 deletion
+32092
-31954
qfluentwidgets/__init__.py
qfluentwidgets/__init__.py
+1
-1
qfluentwidgets/_rc/qss/dark/button.qss
qfluentwidgets/_rc/qss/dark/button.qss
+3
-0
qfluentwidgets/_rc/qss/light/button.qss
qfluentwidgets/_rc/qss/light/button.qss
+3
-0
qfluentwidgets/_rc/resource.py
qfluentwidgets/_rc/resource.py
+31912
-31911
qfluentwidgets/common/overload.py
qfluentwidgets/common/overload.py
+47
-0
qfluentwidgets/components/date_time/picker_base.py
qfluentwidgets/components/date_time/picker_base.py
+12
-2
qfluentwidgets/components/widgets/button.py
qfluentwidgets/components/widgets/button.py
+52
-33
qfluentwidgets/components/widgets/check_box.py
qfluentwidgets/components/widgets/check_box.py
+9
-2
qfluentwidgets/components/widgets/icon_widget.py
qfluentwidgets/components/widgets/icon_widget.py
+20
-3
qfluentwidgets/components/widgets/line_edit.py
qfluentwidgets/components/widgets/line_edit.py
+12
-0
qfluentwidgets/components/widgets/slider.py
qfluentwidgets/components/widgets/slider.py
+8
-1
qfluentwidgets/components/widgets/spin_box.py
qfluentwidgets/components/widgets/spin_box.py
+12
-0
setup.py
setup.py
+1
-1
未找到文件。
qfluentwidgets/__init__.py
浏览文件 @
1794ae68
...
...
@@ -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__
=
"0.7.
2
"
__version__
=
"0.7.
3
"
from
.components
import
*
from
.common
import
*
...
...
qfluentwidgets/_rc/qss/dark/button.qss
浏览文件 @
1794ae68
...
...
@@ -155,14 +155,17 @@ RadioButton::indicator:disabled {
TransparentToolButton {
background-color: transparent;
border: none;
border-radius: 4px;
margin: 0;
}
TransparentToolButton:hover {
background-color: rgba(255, 255, 255, 9);
border: none;
}
TransparentToolButton:pressed {
background-color: rgba(255, 255, 255, 6);
border: none;
}
\ No newline at end of file
qfluentwidgets/_rc/qss/light/button.qss
浏览文件 @
1794ae68
...
...
@@ -155,14 +155,17 @@ RadioButton::indicator:disabled {
TransparentToolButton {
background-color: transparent;
border: none;
border-radius: 4px;
margin: 0;
}
TransparentToolButton:hover {
background-color: rgba(0, 0, 0, 9);
border: none;
}
TransparentToolButton:pressed {
background-color: rgba(0, 0, 0, 6);
border: none;
}
\ No newline at end of file
qfluentwidgets/_rc/resource.py
浏览文件 @
1794ae68
此差异已折叠。
点击以展开。
qfluentwidgets/common/overload.py
0 → 100644
浏览文件 @
1794ae68
# coding: utf-8
from
functools
import
singledispatch
,
update_wrapper
class
singledispatchmethod
:
"""Single-dispatch generic method descriptor.
Supports wrapping existing descriptors and handles non-descriptor
callables as instance methods.
"""
def
__init__
(
self
,
func
):
if
not
callable
(
func
)
and
not
hasattr
(
func
,
"__get__"
):
raise
TypeError
(
f
"
{
func
!
r
}
is not callable or a descriptor"
)
self
.
dispatcher
=
singledispatch
(
func
)
self
.
func
=
func
def
register
(
self
,
cls
,
method
=
None
):
"""generic_method.register(cls, func) -> func
Registers a new implementation for the given *cls* on a *generic_method*.
"""
return
self
.
dispatcher
.
register
(
cls
,
func
=
method
)
def
__get__
(
self
,
obj
,
cls
=
None
):
def
_method
(
*
args
,
**
kwargs
):
if
args
:
method
=
self
.
dispatcher
.
dispatch
(
args
[
0
].
__class__
)
else
:
method
=
self
.
func
for
v
in
kwargs
.
values
():
if
v
.
__class__
in
self
.
dispatcher
.
registry
:
method
=
self
.
dispatcher
.
dispatch
(
v
.
__class__
)
if
method
is
not
self
.
func
:
break
return
method
.
__get__
(
obj
,
cls
)(
*
args
,
**
kwargs
)
_method
.
__isabstractmethod__
=
self
.
__isabstractmethod__
_method
.
register
=
self
.
register
update_wrapper
(
_method
,
self
.
func
)
return
_method
@
property
def
__isabstractmethod__
(
self
):
return
getattr
(
self
.
func
,
'__isabstractmethod__'
,
False
)
qfluentwidgets/components/date_time/picker_base.py
浏览文件 @
1794ae68
...
...
@@ -372,6 +372,16 @@ class PickerBase(QPushButton):
pass
class
PickerToolButton
(
TransparentToolButton
):
""" Picker tool button """
def
_drawIcon
(
self
,
icon
,
painter
,
rect
):
if
self
.
isPressed
:
painter
.
setOpacity
(
1
)
super
().
_drawIcon
(
icon
,
painter
,
rect
)
class
PickerPanel
(
QWidget
):
""" picker panel """
...
...
@@ -386,8 +396,8 @@ class PickerPanel(QWidget):
self
.
view
=
QFrame
(
self
)
self
.
itemMaskWidget
=
ItemMaskWidget
(
self
.
listWidgets
,
self
)
self
.
hSeparatorWidget
=
SeparatorWidget
(
Qt
.
Horizontal
,
self
.
view
)
self
.
yesButton
=
Transparent
ToolButton
(
FluentIcon
.
ACCEPT
,
self
.
view
)
self
.
cancelButton
=
Transparent
ToolButton
(
FluentIcon
.
CLOSE
,
self
.
view
)
self
.
yesButton
=
Picker
ToolButton
(
FluentIcon
.
ACCEPT
,
self
.
view
)
self
.
cancelButton
=
Picker
ToolButton
(
FluentIcon
.
CLOSE
,
self
.
view
)
self
.
hBoxLayout
=
QHBoxLayout
(
self
)
self
.
listLayout
=
QHBoxLayout
()
...
...
qfluentwidgets/components/widgets/button.py
浏览文件 @
1794ae68
...
...
@@ -3,22 +3,29 @@ from typing import Union
from
PyQt5.QtCore
import
QUrl
,
Qt
,
QRectF
,
QSize
from
PyQt5.QtGui
import
QDesktopServices
,
QIcon
,
QPainter
from
PyQt5.QtWidgets
import
QPushButton
,
QRadioButton
,
QToolButton
,
QApplication
from
PyQt5.QtWidgets
import
QPushButton
,
QRadioButton
,
QToolButton
,
QApplication
,
QWidget
from
...common.icon
import
FluentIconBase
,
drawIcon
,
isDarkTheme
,
Theme
from
...common.style_sheet
import
FluentStyleSheet
from
...common.overload
import
singledispatchmethod
class
PushButton
(
QPushButton
):
""" push button """
def
__init__
(
self
,
text
:
str
,
parent
=
None
,
icon
:
Union
[
QIcon
,
str
,
FluentIconBase
]
=
None
):
super
().
__init__
(
text
=
text
,
parent
=
parent
)
@
singledispatchmethod
def
__init__
(
self
,
parent
:
QWidget
=
None
):
super
().
__init__
(
parent
)
FluentStyleSheet
.
BUTTON
.
apply
(
self
)
self
.
_icon
=
icon
self
.
isPressed
=
False
self
.
setProperty
(
'hasIcon'
,
icon
is
not
None
)
self
.
setIconSize
(
QSize
(
16
,
16
))
self
.
setIcon
(
None
)
@
__init__
.
register
def
_
(
self
,
text
:
str
,
parent
:
QWidget
=
None
,
icon
:
Union
[
QIcon
,
str
,
FluentIconBase
]
=
None
):
self
.
__init__
(
parent
=
parent
)
self
.
setText
(
text
)
self
.
setIcon
(
icon
)
def
setIcon
(
self
,
icon
:
Union
[
QIcon
,
str
,
FluentIconBase
]):
self
.
setProperty
(
'hasIcon'
,
icon
is
not
None
)
...
...
@@ -86,30 +93,59 @@ class PrimaryPushButton(PushButton):
class
HyperlinkButton
(
QPushButton
):
""" Hyperlink button """
def
__init__
(
self
,
url
:
str
,
text
:
str
,
parent
=
None
):
super
().
__init__
(
text
,
parent
)
s
elf
.
url
=
QUrl
(
url
)
self
.
clicked
.
connect
(
lambda
i
:
QDesktopServices
.
openUrl
(
self
.
url
)
)
@
singledispatchmethod
def
__init__
(
self
,
parent
:
QWidget
=
None
):
s
uper
().
__init__
(
parent
)
self
.
url
=
QUrl
(
)
FluentStyleSheet
.
BUTTON
.
apply
(
self
)
self
.
setCursor
(
Qt
.
PointingHandCursor
)
self
.
clicked
.
connect
(
lambda
i
:
QDesktopServices
.
openUrl
(
self
.
url
))
@
__init__
.
register
def
_
(
self
,
url
:
str
,
text
:
str
,
parent
:
QWidget
=
None
):
self
.
__init__
(
parent
)
self
.
setText
(
text
)
self
.
url
.
setUrl
(
url
)
class
RadioButton
(
QRadioButton
):
""" Radio button """
def
__init__
(
self
,
text
:
str
,
parent
=
None
):
super
().
__init__
(
text
,
parent
)
@
singledispatchmethod
def
__init__
(
self
,
parent
:
QWidget
=
None
):
super
().
__init__
(
parent
)
FluentStyleSheet
.
BUTTON
.
apply
(
self
)
@
__init__
.
register
def
_
(
self
,
text
:
str
,
parent
:
QWidget
=
None
):
self
.
__init__
(
parent
)
self
.
setText
(
text
)
class
ToolButton
(
QToolButton
):
""" Tool button """
def
__init__
(
self
,
icon
:
Union
[
QIcon
,
str
,
FluentIconBase
],
parent
=
None
):
@
singledispatchmethod
def
__init__
(
self
,
parent
:
QWidget
=
None
):
super
().
__init__
(
parent
)
self
.
_icon
=
icon
self
.
isPressed
=
False
FluentStyleSheet
.
BUTTON
.
apply
(
self
)
self
.
isPressed
=
False
self
.
setIcon
(
QIcon
())
@
__init__
.
register
def
_
(
self
,
icon
:
FluentIconBase
,
parent
:
QWidget
=
None
):
self
.
__init__
(
parent
)
self
.
setIcon
(
icon
)
@
__init__
.
register
def
_
(
self
,
icon
:
QIcon
,
parent
:
QWidget
=
None
):
self
.
__init__
(
parent
)
self
.
setIcon
(
icon
)
@
__init__
.
register
def
_
(
self
,
icon
:
str
,
parent
:
QWidget
=
None
):
self
.
__init__
(
parent
)
self
.
setIcon
(
icon
)
def
setIcon
(
self
,
icon
:
Union
[
QIcon
,
str
,
FluentIconBase
]):
self
.
_icon
=
icon
...
...
@@ -151,26 +187,9 @@ class ToolButton(QToolButton):
w
,
h
=
self
.
iconSize
().
width
(),
self
.
iconSize
().
height
()
y
=
(
self
.
height
()
-
h
)
/
2
x
=
(
self
.
width
()
-
w
)
/
2
x
=
(
self
.
width
()
-
w
)
/
2
self
.
_drawIcon
(
self
.
_icon
,
painter
,
QRectF
(
x
,
y
,
w
,
h
))
class
TransparentToolButton
(
Q
ToolButton
):
class
TransparentToolButton
(
ToolButton
):
""" Transparent background tool button """
def
__init__
(
self
,
icon
:
Union
[
QIcon
,
str
,
FluentIconBase
],
parent
=
None
):
super
().
__init__
(
parent
)
self
.
_icon
=
icon
self
.
setCursor
(
Qt
.
PointingHandCursor
)
FluentStyleSheet
.
BUTTON
.
apply
(
self
)
def
paintEvent
(
self
,
e
):
super
().
paintEvent
(
e
)
painter
=
QPainter
(
self
)
painter
.
setRenderHints
(
QPainter
.
Antialiasing
|
QPainter
.
SmoothPixmapTransform
)
iw
,
ih
=
self
.
iconSize
().
width
(),
self
.
iconSize
().
height
()
w
,
h
=
self
.
width
(),
self
.
height
()
rect
=
QRectF
((
w
-
iw
)
/
2
,
(
h
-
ih
)
/
2
,
iw
,
ih
)
drawIcon
(
self
.
_icon
,
painter
,
rect
)
\ No newline at end of file
qfluentwidgets/components/widgets/check_box.py
浏览文件 @
1794ae68
# coding: utf-8
from
PyQt5.QtWidgets
import
QCheckBox
from
PyQt5.QtWidgets
import
QCheckBox
,
QWidget
from
...common.style_sheet
import
FluentStyleSheet
from
...common.overload
import
singledispatchmethod
class
CheckBox
(
QCheckBox
):
""" Check box """
def
__init__
(
self
,
text
:
str
,
parent
=
None
):
@
singledispatchmethod
def
__init__
(
self
,
parent
:
QWidget
=
None
):
super
().
__init__
(
parent
)
FluentStyleSheet
.
CHECK_BOX
.
apply
(
self
)
@
__init__
.
register
def
_
(
self
,
text
:
str
,
parent
:
QWidget
=
None
):
super
().
__init__
(
text
,
parent
)
FluentStyleSheet
.
CHECK_BOX
.
apply
(
self
)
qfluentwidgets/components/widgets/icon_widget.py
浏览文件 @
1794ae68
...
...
@@ -5,14 +5,31 @@ from PyQt5.QtGui import QIcon, QPainter
from
PyQt5.QtWidgets
import
QWidget
from
...common.icon
import
FluentIconBase
,
drawIcon
from
...common.overload
import
singledispatchmethod
class
IconWidget
(
QWidget
):
""" Icon widget """
def
__init__
(
self
,
icon
:
Union
[
str
,
QIcon
,
FluentIconBase
],
parent
=
None
):
super
().
__init__
(
parent
=
parent
)
self
.
icon
=
icon
@
singledispatchmethod
def
__init__
(
self
,
parent
=
None
):
super
().
__init__
(
parent
)
self
.
setIcon
(
QIcon
())
@
__init__
.
register
def
_
(
self
,
icon
:
FluentIconBase
,
parent
:
QWidget
=
None
):
self
.
__init__
(
parent
)
self
.
setIcon
(
icon
)
@
__init__
.
register
def
_
(
self
,
icon
:
QIcon
,
parent
:
QWidget
=
None
):
self
.
__init__
(
parent
)
self
.
setIcon
(
icon
)
@
__init__
.
register
def
_
(
self
,
icon
:
str
,
parent
:
QWidget
=
None
):
self
.
__init__
(
parent
)
self
.
setIcon
(
icon
)
def
setIcon
(
self
,
icon
:
Union
[
str
,
QIcon
,
FluentIconBase
]):
self
.
icon
=
icon
...
...
qfluentwidgets/components/widgets/line_edit.py
浏览文件 @
1794ae68
...
...
@@ -17,12 +17,21 @@ class LineEditButton(QToolButton):
def
__init__
(
self
,
icon
:
Union
[
str
,
QIcon
,
FluentIconBase
],
parent
=
None
):
super
().
__init__
(
parent
=
parent
)
self
.
_icon
=
icon
self
.
isPressed
=
False
self
.
setFixedSize
(
31
,
23
)
self
.
setIconSize
(
QSize
(
10
,
10
))
self
.
setCursor
(
Qt
.
PointingHandCursor
)
self
.
setObjectName
(
'lineEditButton'
)
FluentStyleSheet
.
LINE_EDIT
.
apply
(
self
)
def
mousePressEvent
(
self
,
e
):
self
.
isPressed
=
True
super
().
mousePressEvent
(
e
)
def
mouseReleaseEvent
(
self
,
e
):
self
.
isPressed
=
False
super
().
mouseReleaseEvent
(
e
)
def
paintEvent
(
self
,
e
):
super
().
paintEvent
(
e
)
painter
=
QPainter
(
self
)
...
...
@@ -33,6 +42,9 @@ class LineEditButton(QToolButton):
w
,
h
=
self
.
width
(),
self
.
height
()
rect
=
QRectF
((
w
-
iw
)
/
2
,
(
h
-
ih
)
/
2
,
iw
,
ih
)
if
self
.
isPressed
:
painter
.
setOpacity
(
0.7
)
if
isDarkTheme
():
drawIcon
(
self
.
_icon
,
painter
,
rect
)
else
:
...
...
qfluentwidgets/components/widgets/slider.py
浏览文件 @
1794ae68
...
...
@@ -5,6 +5,7 @@ from PyQt5.QtWidgets import (QProxyStyle, QSlider, QStyle, QStyleOptionSlider,
QWidget
)
from
...common.style_sheet
import
FluentStyleSheet
from
...common.overload
import
singledispatchmethod
class
Slider
(
QSlider
):
...
...
@@ -12,7 +13,13 @@ class Slider(QSlider):
clicked
=
pyqtSignal
(
int
)
def
__init__
(
self
,
orientation
,
parent
=
None
):
@
singledispatchmethod
def
__init__
(
self
,
parent
:
QWidget
=
None
):
super
().
__init__
(
parent
)
FluentStyleSheet
.
SLIDER
.
apply
(
self
)
@
__init__
.
register
def
_
(
self
,
orientation
:
Qt
.
Orientation
,
parent
:
QWidget
=
None
):
super
().
__init__
(
orientation
,
parent
=
parent
)
FluentStyleSheet
.
SLIDER
.
apply
(
self
)
...
...
qfluentwidgets/components/widgets/spin_box.py
浏览文件 @
1794ae68
...
...
@@ -31,17 +31,29 @@ class SpinButton(QToolButton):
def
__init__
(
self
,
icon
:
SpinIcon
,
parent
=
None
):
super
().
__init__
(
parent
=
parent
)
self
.
isPressed
=
False
self
.
_icon
=
icon
self
.
setFixedSize
(
31
,
23
)
self
.
setIconSize
(
QSize
(
10
,
10
))
FluentStyleSheet
.
SPIN_BOX
.
apply
(
self
)
def
mousePressEvent
(
self
,
e
):
self
.
isPressed
=
True
super
().
mousePressEvent
(
e
)
def
mouseReleaseEvent
(
self
,
e
):
self
.
isPressed
=
False
super
().
mouseReleaseEvent
(
e
)
def
paintEvent
(
self
,
e
):
super
().
paintEvent
(
e
)
painter
=
QPainter
(
self
)
painter
.
setRenderHints
(
QPainter
.
Antialiasing
|
QPainter
.
SmoothPixmapTransform
)
if
self
.
isPressed
:
painter
.
setOpacity
(
0.7
)
self
.
_icon
.
render
(
painter
,
QRectF
(
10
,
9
,
11
,
11
))
...
...
setup.py
浏览文件 @
1794ae68
...
...
@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools
.
setup
(
name
=
"PyQt-Fluent-Widgets"
,
version
=
"0.7.
2
"
,
version
=
"0.7.
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录