Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
395279cb
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看板
提交
395279cb
编写于
5月 19, 2023
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加 Pivot
上级
7046b722
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
77386 addition
and
77017 deletion
+77386
-77017
examples/pivot/demo.py
examples/pivot/demo.py
+70
-0
plugins/navigation_plugin.py
plugins/navigation_plugin.py
+19
-1
qfluentwidgets/_rc/qss/dark/pivot.qss
qfluentwidgets/_rc/qss/dark/pivot.qss
+28
-0
qfluentwidgets/_rc/qss/light/pivot.qss
qfluentwidgets/_rc/qss/light/pivot.qss
+29
-0
qfluentwidgets/_rc/resource.py
qfluentwidgets/_rc/resource.py
+77092
-77015
qfluentwidgets/_rc/resource.qrc
qfluentwidgets/_rc/resource.qrc
+2
-0
qfluentwidgets/common/style_sheet.py
qfluentwidgets/common/style_sheet.py
+1
-0
qfluentwidgets/components/navigation/__init__.py
qfluentwidgets/components/navigation/__init__.py
+2
-1
qfluentwidgets/components/navigation/pivot.py
qfluentwidgets/components/navigation/pivot.py
+143
-0
未找到文件。
examples/pivot/demo.py
0 → 100644
浏览文件 @
395279cb
# coding:utf-8
import
sys
from
PyQt5.QtCore
import
Qt
from
PyQt5.QtWidgets
import
QApplication
,
QWidget
,
QStackedWidget
,
QVBoxLayout
,
QLabel
from
qfluentwidgets
import
Pivot
,
setTheme
,
Theme
class
Demo
(
QWidget
):
def
__init__
(
self
):
super
().
__init__
()
# setTheme(Theme.DARK)
self
.
setStyleSheet
(
"""
Demo{background: white}
QLabel{
font: 20px 'Segoe UI';
background: rgb(242,242,242);
border-radius: 8px;
}
"""
)
self
.
resize
(
400
,
400
)
self
.
pivot
=
Pivot
(
self
)
self
.
stackedWidget
=
QStackedWidget
(
self
)
self
.
vBoxLayout
=
QVBoxLayout
(
self
)
self
.
songInterface
=
QLabel
(
'Song Interface'
,
self
)
self
.
albumInterface
=
QLabel
(
'Album Interface'
,
self
)
self
.
artistInterface
=
QLabel
(
'Artist Interface'
,
self
)
# add items to pivot
self
.
addSubInterface
(
self
.
songInterface
,
'songInterface'
,
'Song'
)
self
.
addSubInterface
(
self
.
albumInterface
,
'albumInterface'
,
'Album'
)
self
.
addSubInterface
(
self
.
artistInterface
,
'artistInterface'
,
'Artist'
)
self
.
vBoxLayout
.
addWidget
(
self
.
pivot
,
0
,
Qt
.
AlignHCenter
)
self
.
vBoxLayout
.
addWidget
(
self
.
stackedWidget
)
self
.
vBoxLayout
.
setContentsMargins
(
30
,
0
,
30
,
30
)
self
.
stackedWidget
.
currentChanged
.
connect
(
self
.
onCurrentIndexChanged
)
self
.
stackedWidget
.
setCurrentWidget
(
self
.
songInterface
)
self
.
pivot
.
setCurrentItem
(
self
.
songInterface
.
objectName
())
def
addSubInterface
(
self
,
widget
:
QLabel
,
objectName
,
text
):
widget
.
setObjectName
(
objectName
)
widget
.
setAlignment
(
Qt
.
AlignCenter
)
self
.
stackedWidget
.
addWidget
(
widget
)
self
.
pivot
.
addItem
(
routeKey
=
objectName
,
text
=
text
,
onClick
=
lambda
:
self
.
stackedWidget
.
setCurrentWidget
(
widget
)
)
def
onCurrentIndexChanged
(
self
,
index
):
widget
=
self
.
stackedWidget
.
widget
(
index
)
self
.
pivot
.
setCurrentItem
(
widget
.
objectName
())
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_
()
\ No newline at end of file
plugins/navigation_plugin.py
浏览文件 @
395279cb
...
...
@@ -2,7 +2,7 @@
from
PyQt5.QtCore
import
Qt
from
PyQt5.QtDesigner
import
QPyDesignerCustomWidgetPlugin
from
qfluentwidgets
import
NavigationInterface
,
NavigationPanel
from
qfluentwidgets
import
NavigationInterface
,
NavigationPanel
,
Pivot
from
plugin_base
import
PluginBase
...
...
@@ -37,3 +37,21 @@ class NavigationPanelPlugin(NavigationPlugin, QPyDesignerCustomWidgetPlugin):
def
name
(
self
):
return
"NavigationPanel"
class
PivotPlugin
(
NavigationPlugin
,
QPyDesignerCustomWidgetPlugin
):
""" Navigation panel plugin """
def
createWidget
(
self
,
parent
):
p
=
Pivot
(
parent
)
for
i
in
range
(
1
,
4
):
p
.
addItem
(
f
'Item
{
i
}
'
,
f
'Item
{
i
}
'
,
print
)
p
.
setCurrentItem
(
'Item1'
)
return
p
def
icon
(
self
):
return
super
().
icon
(
"Pivot"
)
def
name
(
self
):
return
"Pivot"
qfluentwidgets/_rc/qss/dark/pivot.qss
0 → 100644
浏览文件 @
395279cb
PivotItem {
padding: 10px 12px;
color: white;
background-color: transparent;
border: none;
outline: none;
}
PivotItem[isSelected=true]:hover {
color: rgba(255, 255, 255, 0.63);
}
PivotItem[isSelected=true]:pressed {
color: rgba(255, 255, 255, 0.53);
}
PivotItem[isSelected=false]:pressed {
color: rgba(255, 255, 255, 0.75);
}
Pivot {
border: none;
background-color: transparent;
}
#view {
background-color: transparent;
}
\ No newline at end of file
qfluentwidgets/_rc/qss/light/pivot.qss
0 → 100644
浏览文件 @
395279cb
PivotItem {
padding: 10px 12px;
color: black;
background-color: transparent;
border: none;
outline: none;
margin: 0;
}
PivotItem[isSelected=true]:hover {
color: rgba(0, 0, 0, 0.63);
}
PivotItem[isSelected=true]:pressed {
color: rgba(0, 0, 0, 0.53);
}
PivotItem[isSelected=false]:pressed {
color: rgba(0, 0, 0, 0.75);
}
Pivot {
border: none;
background-color: transparent;
}
#view {
background-color: transparent;
}
\ No newline at end of file
qfluentwidgets/_rc/resource.py
浏览文件 @
395279cb
此差异已折叠。
点击以展开。
qfluentwidgets/_rc/resource.qrc
浏览文件 @
395279cb
...
...
@@ -230,6 +230,7 @@
<file>qss/dark/tree_view.qss</file>
<file>qss/dark/table_view.qss</file>
<file>qss/dark/time_picker.qss</file>
<file>qss/dark/pivot.qss</file>
<file>qss/light/color_dialog.qss</file>
<file>qss/light/dialog.qss</file>
...
...
@@ -254,6 +255,7 @@
<file>qss/light/table_view.qss</file>
<file>qss/light/tree_view.qss</file>
<file>qss/light/time_picker.qss</file>
<file>qss/light/pivot.qss</file>
<file>i18n/qfluentwidgets.zh_CN.qm</file>
<file>i18n/qfluentwidgets.zh_HK.qm</file>
...
...
qfluentwidgets/common/style_sheet.py
浏览文件 @
395279cb
...
...
@@ -87,6 +87,7 @@ class FluentStyleSheet(StyleSheetBase, Enum):
""" Fluent style sheet """
MENU
=
"menu"
PIVOT
=
"pivot"
BUTTON
=
"button"
DIALOG
=
"dialog"
SLIDER
=
"slider"
...
...
qfluentwidgets/components/navigation/__init__.py
浏览文件 @
395279cb
from
.navigation_widget
import
NavigationWidget
,
NavigationPushButton
,
NavigationSeparator
,
NavigationToolButton
from
.navigation_panel
import
NavigationPanel
,
NavigationItemPosition
,
NavigationDisplayMode
from
.navigation_interface
import
NavigationInterface
\ No newline at end of file
from
.navigation_interface
import
NavigationInterface
from
.pivot
import
Pivot
,
PivotItem
\ No newline at end of file
qfluentwidgets/components/navigation/pivot.py
0 → 100644
浏览文件 @
395279cb
# coding:utf-8
from
typing
import
Dict
from
PyQt5.QtCore
import
Qt
,
pyqtSignal
from
PyQt5.QtGui
import
QPainter
,
QFont
from
PyQt5.QtWidgets
import
QApplication
,
QPushButton
,
QWidget
,
QHBoxLayout
,
QSizePolicy
from
...common.style_sheet
import
themeColor
,
FluentStyleSheet
from
..widgets.scroll_area
import
SingleDirectionScrollArea
class
PivotItem
(
QPushButton
):
""" Pivot item """
itemClicked
=
pyqtSignal
(
bool
)
def
__init__
(
self
,
text
:
str
,
parent
=
None
):
super
().
__init__
(
text
,
parent
)
self
.
isSelected
=
False
self
.
setProperty
(
'isSelected'
,
False
)
self
.
clicked
.
connect
(
lambda
:
self
.
itemClicked
.
emit
(
True
))
font
=
QFont
()
font
.
setFamilies
([
'Segoe UI'
,
'Microsoft YaHei'
])
font
.
setPixelSize
(
18
)
self
.
setFont
(
font
)
def
setSelected
(
self
,
isSelected
:
bool
):
if
self
.
isSelected
==
isSelected
:
return
self
.
isSelected
=
isSelected
self
.
setProperty
(
'isSelected'
,
isSelected
)
self
.
setStyle
(
QApplication
.
style
())
self
.
update
()
def
paintEvent
(
self
,
e
):
super
().
paintEvent
(
e
)
if
not
self
.
isSelected
:
return
painter
=
QPainter
(
self
)
painter
.
setRenderHints
(
QPainter
.
Antialiasing
)
painter
.
setPen
(
Qt
.
NoPen
)
painter
.
setBrush
(
themeColor
())
x
=
int
(
self
.
width
()
/
2
-
8
)
painter
.
drawRoundedRect
(
x
,
self
.
height
()
-
3
,
16
,
3
,
1.5
,
1.5
)
class
Pivot
(
QWidget
):
""" Pivot """
def
__init__
(
self
,
parent
=
None
):
super
().
__init__
(
parent
)
self
.
items
=
{}
# type: Dict[str, PivotItem]
self
.
hBoxLayout
=
QHBoxLayout
(
self
)
# self.setWidget(self.view)
# self.setWidgetResizable(True)
# self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
# self.setViewportMargins(0, 0, 0, 0)
FluentStyleSheet
.
PIVOT
.
apply
(
self
)
self
.
hBoxLayout
.
setSpacing
(
0
)
self
.
hBoxLayout
.
setAlignment
(
Qt
.
AlignLeft
)
self
.
hBoxLayout
.
setContentsMargins
(
0
,
0
,
0
,
0
)
self
.
hBoxLayout
.
setSizeConstraint
(
QHBoxLayout
.
SetMinimumSize
)
self
.
setSizePolicy
(
QSizePolicy
.
Minimum
,
QSizePolicy
.
Minimum
)
def
addItem
(
self
,
routeKey
:
str
,
text
:
str
,
onClick
):
""" add item
Parameters
----------
routeKey: str
the unique name of item
text: str
the text of navigation item
onClick: callable
the slot connected to item clicked signal
"""
return
self
.
insertItem
(
-
1
,
routeKey
,
text
,
onClick
)
def
insertItem
(
self
,
index
:
int
,
routeKey
:
str
,
text
:
str
,
onClick
):
""" insert item
Parameters
----------
index: int
insert position
routeKey: str
the unique name of item
text: str
the text of navigation item
onClick: callable
the slot connected to item clicked signal
"""
if
routeKey
in
self
.
items
:
return
item
=
PivotItem
(
text
,
self
)
item
.
setProperty
(
'routeKey'
,
routeKey
)
item
.
itemClicked
.
connect
(
self
.
_onItemClicked
)
item
.
itemClicked
.
connect
(
onClick
)
self
.
items
[
routeKey
]
=
item
self
.
hBoxLayout
.
insertWidget
(
index
,
item
,
0
,
Qt
.
AlignLeft
)
return
item
def
setCurrentItem
(
self
,
routeKey
:
str
):
""" set current selected item
Parameters
----------
routeKey: str
the unique name of item
"""
if
routeKey
not
in
self
.
items
:
return
for
k
,
item
in
self
.
items
.
items
():
item
.
setSelected
(
k
==
routeKey
)
def
setItemFontSize
(
self
,
size
:
int
):
""" set the pixel font size of items """
for
item
in
self
.
items
.
values
():
font
=
item
.
font
()
font
.
setPixelSize
(
size
)
item
.
setFont
(
font
)
item
.
adjustSize
()
def
_onItemClicked
(
self
):
item
=
self
.
sender
()
# type: PivotItem
self
.
setCurrentItem
(
item
.
property
(
'routeKey'
))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录