Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
5c4109d1
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看板
提交
5c4109d1
编写于
7月 02, 2023
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加 `PillPushButton` 和 `PillToolButton`
上级
1176c477
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
85718 addition
and
85550 deletion
+85718
-85550
examples/button/demo.py
examples/button/demo.py
+20
-2
examples/gallery/app/view/basic_input_interface.py
examples/gallery/app/view/basic_input_interface.py
+16
-1
examples/gallery/app/view/home_interface.py
examples/gallery/app/view/home_interface.py
+9
-9
plugins/basic_input_plugin.py
plugins/basic_input_plugin.py
+28
-1
qfluentwidgets/__init__.py
qfluentwidgets/__init__.py
+1
-1
qfluentwidgets/_rc/qss/dark/button.qss
qfluentwidgets/_rc/qss/dark/button.qss
+20
-0
qfluentwidgets/_rc/qss/light/button.qss
qfluentwidgets/_rc/qss/light/button.qss
+21
-0
qfluentwidgets/_rc/resource.py
qfluentwidgets/_rc/resource.py
+85538
-85531
qfluentwidgets/components/widgets/__init__.py
qfluentwidgets/components/widgets/__init__.py
+2
-1
qfluentwidgets/components/widgets/button.py
qfluentwidgets/components/widgets/button.py
+62
-3
setup.py
setup.py
+1
-1
未找到文件。
examples/button/demo.py
浏览文件 @
5c4109d1
...
...
@@ -9,7 +9,7 @@ from qfluentwidgets import (Action, DropDownPushButton, DropDownToolButton, Push
PrimarySplitToolButton
,
PrimaryDropDownPushButton
,
PrimaryDropDownToolButton
,
TogglePushButton
,
ToggleToolButton
,
TransparentPushButton
,
TransparentToolButton
,
TransparentToggleToolButton
,
TransparentTogglePushButton
,
TransparentDropDownToolButton
,
TransparentDropDownPushButton
)
TransparentDropDownPushButton
,
PillPushButton
,
PillToolButton
)
from
qfluentwidgets
import
FluentIcon
as
FIF
...
...
@@ -65,6 +65,14 @@ class ToolButtonDemo(QWidget):
self
.
transparentDropDownToolButton
=
TransparentDropDownToolButton
(
FIF
.
MAIL
,
self
)
self
.
transparentDropDownToolButton
.
setMenu
(
self
.
menu
)
# pill tool button
self
.
pillToolButton1
=
PillToolButton
(
FIF
.
CALENDAR
,
self
)
self
.
pillToolButton2
=
PillToolButton
(
FIF
.
CALENDAR
,
self
)
self
.
pillToolButton3
=
PillToolButton
(
FIF
.
CALENDAR
,
self
)
self
.
pillToolButton2
.
setDisabled
(
True
)
self
.
pillToolButton3
.
setChecked
(
True
)
self
.
pillToolButton3
.
setDisabled
(
True
)
# add buttons to layout
self
.
gridLayout
=
QGridLayout
(
self
)
self
.
gridLayout
.
addWidget
(
self
.
toolButton
,
0
,
0
)
...
...
@@ -77,6 +85,9 @@ class ToolButtonDemo(QWidget):
self
.
gridLayout
.
addWidget
(
self
.
transparentToggleToolButton
,
2
,
1
)
self
.
gridLayout
.
addWidget
(
self
.
tranparentToolButton
,
3
,
0
)
self
.
gridLayout
.
addWidget
(
self
.
transparentDropDownToolButton
,
3
,
1
)
self
.
gridLayout
.
addWidget
(
self
.
pillToolButton1
,
4
,
0
)
self
.
gridLayout
.
addWidget
(
self
.
pillToolButton2
,
4
,
1
)
self
.
gridLayout
.
addWidget
(
self
.
pillToolButton3
,
4
,
2
)
self
.
resize
(
300
,
300
)
...
...
@@ -150,6 +161,10 @@ class PushButtonDemo(QWidget):
parent
=
self
)
# pill push button
self
.
pillPushButton1
=
PillPushButton
(
'Pill Push Button'
,
self
)
self
.
pillPushButton2
=
PillPushButton
(
'Pill Push Button'
,
self
,
FIF
.
CALENDAR
)
self
.
gridLayout
=
QGridLayout
(
self
)
self
.
gridLayout
.
addWidget
(
self
.
pushButton1
,
0
,
0
)
self
.
gridLayout
.
addWidget
(
self
.
pushButton2
,
0
,
1
)
...
...
@@ -175,7 +190,10 @@ class PushButtonDemo(QWidget):
self
.
gridLayout
.
addWidget
(
self
.
transparentDropDownPushButton1
,
9
,
0
,
Qt
.
AlignLeft
)
self
.
gridLayout
.
addWidget
(
self
.
transparentDropDownPushButton2
,
9
,
1
,
Qt
.
AlignLeft
)
self
.
gridLayout
.
addWidget
(
self
.
hyperlinkButton
,
10
,
0
)
self
.
gridLayout
.
addWidget
(
self
.
pillPushButton1
,
10
,
0
,
Qt
.
AlignLeft
)
self
.
gridLayout
.
addWidget
(
self
.
pillPushButton2
,
10
,
1
,
Qt
.
AlignLeft
)
self
.
gridLayout
.
addWidget
(
self
.
hyperlinkButton
,
11
,
0
)
self
.
resize
(
600
,
700
)
...
...
examples/gallery/app/view/basic_input_interface.py
浏览文件 @
5c4109d1
...
...
@@ -6,7 +6,8 @@ from qfluentwidgets import (Action, DropDownPushButton, DropDownToolButton, Push
ToggleButton
,
RoundMenu
,
FluentIcon
,
SplitPushButton
,
SplitToolButton
,
PrimarySplitToolButton
,
PrimarySplitPushButton
,
PrimaryDropDownPushButton
,
PrimaryToolButton
,
PrimaryDropDownToolButton
,
ToggleToolButton
,
TransparentDropDownPushButton
,
TransparentPushButton
,
TransparentToggleToolButton
,
TransparentTogglePushButton
,
TransparentDropDownToolButton
,
TransparentToolButton
)
TransparentTogglePushButton
,
TransparentDropDownToolButton
,
TransparentToolButton
,
PillPushButton
,
PillToolButton
)
from
.gallery_interface
import
GalleryInterface
from
..common.translator
import
Translator
...
...
@@ -55,6 +56,20 @@ class BasicInputInterface(GalleryInterface):
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/button/demo.py'
)
# pill push button
self
.
addExampleCard
(
self
.
tr
(
'Pill push button'
),
PillPushButton
(
self
.
tr
(
'Tag'
),
self
,
FluentIcon
.
TAG
),
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/button/demo.py'
)
# pill tool button
self
.
addExampleCard
(
self
.
tr
(
'Pill tool button'
),
PillToolButton
(
FluentIcon
.
BASKETBALL
),
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/button/demo.py'
)
# transparent push button
self
.
addExampleCard
(
self
.
tr
(
'A transparent push button'
),
...
...
examples/gallery/app/view/home_interface.py
浏览文件 @
5c4109d1
...
...
@@ -134,7 +134,7 @@ class HomeInterface(ScrollArea):
title
=
"CheckBox"
,
content
=
self
.
tr
(
"A control that a user can select or clear."
),
routeKey
=
"basicInputInterface"
,
index
=
7
index
=
8
)
basicInputView
.
addSampleCard
(
icon
=
":/gallery/images/controls/ComboBox.png"
,
...
...
@@ -142,7 +142,7 @@ class HomeInterface(ScrollArea):
content
=
self
.
tr
(
"A drop-down list of items a user can select from."
),
routeKey
=
"basicInputInterface"
,
index
=
9
index
=
10
)
basicInputView
.
addSampleCard
(
icon
=
":/gallery/images/controls/DropDownButton.png"
,
...
...
@@ -150,7 +150,7 @@ class HomeInterface(ScrollArea):
content
=
self
.
tr
(
"A button that displays a flyout of choices when clicked."
),
routeKey
=
"basicInputInterface"
,
index
=
1
1
index
=
1
2
)
basicInputView
.
addSampleCard
(
icon
=
":/gallery/images/controls/HyperlinkButton.png"
,
...
...
@@ -158,7 +158,7 @@ class HomeInterface(ScrollArea):
content
=
self
.
tr
(
"A button that appears as hyperlink text, and can navigate to a URI or handle a Click event."
),
routeKey
=
"basicInputInterface"
,
index
=
1
6
index
=
1
8
)
basicInputView
.
addSampleCard
(
icon
=
":/gallery/images/controls/RadioButton.png"
,
...
...
@@ -166,7 +166,7 @@ class HomeInterface(ScrollArea):
content
=
self
.
tr
(
"A control that allows a user to select a single option from a group of options."
),
routeKey
=
"basicInputInterface"
,
index
=
1
7
index
=
1
9
)
basicInputView
.
addSampleCard
(
icon
=
":/gallery/images/controls/Slider.png"
,
...
...
@@ -174,7 +174,7 @@ class HomeInterface(ScrollArea):
content
=
self
.
tr
(
"A control that lets the user select from a range of values by moving a Thumb control along a track."
),
routeKey
=
"basicInputInterface"
,
index
=
18
index
=
20
)
basicInputView
.
addSampleCard
(
icon
=
":/gallery/images/controls/SplitButton.png"
,
...
...
@@ -182,7 +182,7 @@ class HomeInterface(ScrollArea):
content
=
self
.
tr
(
"A two-part button that displays a flyout when its secondary part is clicked."
),
routeKey
=
"basicInputInterface"
,
index
=
19
index
=
21
)
basicInputView
.
addSampleCard
(
icon
=
":/gallery/images/controls/ToggleSwitch.png"
,
...
...
@@ -190,7 +190,7 @@ class HomeInterface(ScrollArea):
content
=
self
.
tr
(
"A switch that can be toggled between 2 states."
),
routeKey
=
"basicInputInterface"
,
index
=
2
3
index
=
2
5
)
basicInputView
.
addSampleCard
(
icon
=
":/gallery/images/controls/ToggleButton.png"
,
...
...
@@ -198,7 +198,7 @@ class HomeInterface(ScrollArea):
content
=
self
.
tr
(
"A button that can be switched between two states like a CheckBox."
),
routeKey
=
"basicInputInterface"
,
index
=
2
4
index
=
2
6
)
self
.
vBoxLayout
.
addWidget
(
basicInputView
)
...
...
plugins/basic_input_plugin.py
浏览文件 @
5c4109d1
...
...
@@ -7,7 +7,8 @@ from qfluentwidgets import (PrimaryPushButton, SplitPushButton, DropDownPushButt
EditableComboBox
,
PixmapLabel
,
PushButton
,
PrimaryToolButton
,
PrimarySplitToolButton
,
PrimarySplitPushButton
,
PrimaryDropDownPushButton
,
PrimaryDropDownToolButton
,
TransparentToolButton
,
TransparentPushButton
,
ToggleToolButton
,
TransparentToggleToolButton
,
TransparentTogglePushButton
,
TransparentDropDownPushButton
,
TransparentDropDownToolButton
)
TransparentTogglePushButton
,
TransparentDropDownPushButton
,
TransparentDropDownToolButton
,
PillPushButton
,
PillToolButton
)
from
plugin_base
import
PluginBase
from
task_menu_factory
import
EditTextTaskMenuFactory
...
...
@@ -110,6 +111,19 @@ class PrimaryPushButtonPlugin(TextPlugin, QPyDesignerCustomWidgetPlugin):
return
"PrimaryPushButton"
class
PillPushButtonPlugin
(
TextPlugin
,
QPyDesignerCustomWidgetPlugin
):
""" Pill push button plugin """
def
createWidget
(
self
,
parent
):
return
PillPushButton
(
self
.
toolTip
(),
parent
)
def
icon
(
self
):
return
super
().
icon
(
'Button'
)
def
name
(
self
):
return
"PillPushButton"
class
DropDownPushButtonPlugin
(
TextPlugin
,
QPyDesignerCustomWidgetPlugin
):
""" Drop down push button plugin """
...
...
@@ -208,6 +222,19 @@ class PrimaryToolButtonPlugin(BasicInputPlugin, QPyDesignerCustomWidgetPlugin):
return
"PrimaryToolButton"
class
PillToolButtonPlugin
(
BasicInputPlugin
,
QPyDesignerCustomWidgetPlugin
):
""" Pill tool button plugin """
def
createWidget
(
self
,
parent
):
return
PillToolButton
(
FluentIcon
.
BASKETBALL
,
parent
)
def
icon
(
self
):
return
super
().
icon
(
'Button'
)
def
name
(
self
):
return
"PillToolButton"
class
TransparentToolButtonPlugin
(
BasicInputPlugin
,
QPyDesignerCustomWidgetPlugin
):
""" Primary color tool button plugin """
...
...
qfluentwidgets/__init__.py
浏览文件 @
5c4109d1
...
...
@@ -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.10.
1
"
__version__
=
"0.10.
2
"
from
.components
import
*
from
.common
import
*
...
...
qfluentwidgets/_rc/qss/dark/button.qss
浏览文件 @
5c4109d1
...
...
@@ -261,4 +261,24 @@ TransparentDropDownPushButton:disabled,
TransprentTogglePushButton:disabled {
background-color: transparent;
border: none;
}
PillPushButton,
PillPushButton:hover,
PillPushButton:pressed,
PillPushButton:disabled,
PillPushButton:checked,
PillPushButton:checked:hover,
PillPushButton:checked:pressed,
PillPushButton:disabled:checked,
PillToolButton,
PillToolButton:hover,
PillToolButton:pressed,
PillToolButton:disabled,
PillToolButton:checked,
PillToolButton:checked:hover,
PillToolButton:checked:pressed,
PillToolButton:disabled:checked {
background-color: transparent;
border: none;
}
\ No newline at end of file
qfluentwidgets/_rc/qss/light/button.qss
浏览文件 @
5c4109d1
...
...
@@ -262,3 +262,24 @@ TransprentTogglePushButton:disabled {
background-color: transparent;
border: none;
}
PillPushButton,
PillPushButton:hover,
PillPushButton:pressed,
PillPushButton:disabled,
PillPushButton:checked,
PillPushButton:checked:hover,
PillPushButton:checked:pressed,
PillPushButton:disabled:checked,
PillToolButton,
PillToolButton:hover,
PillToolButton:pressed,
PillToolButton:disabled,
PillToolButton:checked,
PillToolButton:checked:hover,
PillToolButton:checked:pressed,
PillToolButton:disabled:checked {
background-color: transparent;
border: none;
}
qfluentwidgets/_rc/resource.py
浏览文件 @
5c4109d1
此差异已折叠。
点击以展开。
qfluentwidgets/components/widgets/__init__.py
浏览文件 @
5c4109d1
...
...
@@ -3,7 +3,8 @@ from .button import (DropDownPushButton, DropDownToolButton, PrimaryPushButton,
SplitPushButton
,
SplitToolButton
,
PrimaryToolButton
,
PrimarySplitPushButton
,
PrimarySplitToolButton
,
PrimaryDropDownPushButton
,
PrimaryDropDownToolButton
,
TogglePushButton
,
ToggleToolButton
,
TransparentPushButton
,
TransparentTogglePushButton
,
TransparentToggleToolButton
,
TransparentDropDownPushButton
,
TransparentDropDownToolButton
)
TransparentToggleToolButton
,
TransparentDropDownPushButton
,
TransparentDropDownToolButton
,
PillPushButton
,
PillToolButton
)
from
.card_widget
import
CardWidget
from
.check_box
import
CheckBox
from
.combo_box
import
ComboBox
,
EditableComboBox
...
...
qfluentwidgets/components/widgets/button.py
浏览文件 @
5c4109d1
...
...
@@ -2,14 +2,14 @@
from
typing
import
Union
from
PyQt5.QtCore
import
pyqtSignal
,
QUrl
,
Qt
,
QRectF
,
QSize
,
QPoint
,
pyqtProperty
from
PyQt5.QtGui
import
QDesktopServices
,
QIcon
,
QPainter
,
Q
Font
from
PyQt5.QtGui
import
QDesktopServices
,
QIcon
,
QPainter
,
Q
Color
from
PyQt5.QtWidgets
import
QHBoxLayout
,
QPushButton
,
QRadioButton
,
QToolButton
,
QApplication
,
QWidget
,
QSizePolicy
from
...common.animation
import
TranslateYAnimation
from
...common.icon
import
FluentIconBase
,
drawIcon
,
isDarkTheme
,
Theme
,
toQIcon
,
Icon
from
...common.icon
import
FluentIcon
as
FIF
from
...common.font
import
setFont
from
...common.style_sheet
import
FluentStyleSheet
from
...common.style_sheet
import
FluentStyleSheet
,
themeColor
,
ThemeColor
from
...common.overload
import
singledispatchmethod
from
.menu
import
RoundMenu
...
...
@@ -353,7 +353,8 @@ class DropDownButtonBase:
elif
self
.
isPressed
:
painter
.
setOpacity
(
0.7
)
rect
=
QRectF
(
self
.
width
()
-
22
,
self
.
height
()
/
2
-
5
+
self
.
arrowAni
.
y
,
10
,
10
)
rect
=
QRectF
(
self
.
width
()
-
22
,
self
.
height
()
/
2
-
5
+
self
.
arrowAni
.
y
,
10
,
10
)
self
.
_drawDropDownIcon
(
painter
,
rect
)
...
...
@@ -648,3 +649,61 @@ class PrimarySplitToolButton(SplitToolButton):
self
.
button
.
setObjectName
(
'primarySplitToolButton'
)
self
.
button
.
clicked
.
connect
(
self
.
clicked
)
self
.
setWidget
(
self
.
button
)
class
PillButtonBase
:
""" Pill button base class """
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
def
paintEvent
(
self
,
e
):
painter
=
QPainter
(
self
)
painter
.
setRenderHints
(
QPainter
.
Antialiasing
)
isDark
=
isDarkTheme
()
if
not
self
.
isChecked
():
rect
=
self
.
rect
().
adjusted
(
1
,
1
,
-
1
,
-
1
)
borderColor
=
QColor
(
255
,
255
,
255
,
18
)
if
isDark
else
QColor
(
0
,
0
,
0
,
15
)
if
not
self
.
isEnabled
():
bgColor
=
QColor
(
255
,
255
,
255
,
11
)
if
isDark
else
QColor
(
249
,
249
,
249
,
75
)
elif
self
.
isPressed
or
self
.
isHover
:
bgColor
=
QColor
(
255
,
255
,
255
,
21
)
if
isDark
else
QColor
(
249
,
249
,
249
,
128
)
else
:
bgColor
=
QColor
(
255
,
255
,
255
,
15
)
if
isDark
else
QColor
(
243
,
243
,
243
,
194
)
else
:
if
not
self
.
isEnabled
():
bgColor
=
QColor
(
255
,
255
,
255
,
40
)
if
isDark
else
QColor
(
0
,
0
,
0
,
55
)
elif
self
.
isPressed
:
bgColor
=
ThemeColor
.
DARK_2
.
color
()
if
isDark
else
ThemeColor
.
LIGHT_3
.
color
()
elif
self
.
isHover
:
bgColor
=
ThemeColor
.
DARK_1
.
color
()
if
isDark
else
ThemeColor
.
LIGHT_1
.
color
()
else
:
bgColor
=
themeColor
()
borderColor
=
Qt
.
transparent
rect
=
self
.
rect
()
painter
.
setPen
(
borderColor
)
painter
.
setBrush
(
bgColor
)
r
=
rect
.
height
()
/
2
painter
.
drawRoundedRect
(
rect
,
r
,
r
)
class
PillPushButton
(
TogglePushButton
,
PillButtonBase
):
""" Pill push button """
def
paintEvent
(
self
,
e
):
PillButtonBase
.
paintEvent
(
self
,
e
)
TogglePushButton
.
paintEvent
(
self
,
e
)
class
PillToolButton
(
ToggleToolButton
,
PillButtonBase
):
""" Pill push button """
def
paintEvent
(
self
,
e
):
PillButtonBase
.
paintEvent
(
self
,
e
)
ToggleToolButton
.
paintEvent
(
self
,
e
)
\ No newline at end of file
setup.py
浏览文件 @
5c4109d1
...
...
@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools
.
setup
(
name
=
"PyQt-Fluent-Widgets"
,
version
=
"0.10.
1
"
,
version
=
"0.10.
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录