Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
1874a838
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看板
提交
1874a838
编写于
3月 26, 2023
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加更多 gallery 界面
上级
e431d69b
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
365 addition
and
24 deletion
+365
-24
examples/gallery/app/common/icon.py
examples/gallery/app/common/icon.py
+1
-0
examples/gallery/app/common/translator.py
examples/gallery/app/common/translator.py
+1
-0
examples/gallery/app/resource/images/chidanta.jpg
examples/gallery/app/resource/images/chidanta.jpg
+0
-0
examples/gallery/app/resource/images/chidanta2.jpg
examples/gallery/app/resource/images/chidanta2.jpg
+0
-0
examples/gallery/app/resource/images/icons/Scroll_black.svg
examples/gallery/app/resource/images/icons/Scroll_black.svg
+4
-0
examples/gallery/app/resource/images/icons/Scroll_white.svg
examples/gallery/app/resource/images/icons/Scroll_white.svg
+4
-0
examples/gallery/app/resource/qss/dark/gallery_interface.qss
examples/gallery/app/resource/qss/dark/gallery_interface.qss
+5
-1
examples/gallery/app/resource/qss/light/gallery_interface.qss
...ples/gallery/app/resource/qss/light/gallery_interface.qss
+6
-1
examples/gallery/app/view/basic_input_interface.py
examples/gallery/app/view/basic_input_interface.py
+9
-1
examples/gallery/app/view/dialog_interface.py
examples/gallery/app/view/dialog_interface.py
+1
-3
examples/gallery/app/view/gallery_interface.py
examples/gallery/app/view/gallery_interface.py
+21
-4
examples/gallery/app/view/layout_interface.py
examples/gallery/app/view/layout_interface.py
+52
-0
examples/gallery/app/view/main_window.py
examples/gallery/app/view/main_window.py
+40
-11
examples/gallery/app/view/material_interface.py
examples/gallery/app/view/material_interface.py
+30
-0
examples/gallery/app/view/menu_interface.py
examples/gallery/app/view/menu_interface.py
+68
-0
examples/gallery/app/view/scroll_interface.py
examples/gallery/app/view/scroll_interface.py
+37
-0
examples/gallery/app/view/status_info_interface.py
examples/gallery/app/view/status_info_interface.py
+63
-0
qfluentwidgets/components/navigation/navigation_panel.py
qfluentwidgets/components/navigation/navigation_panel.py
+6
-1
qfluentwidgets/components/widgets/label.py
qfluentwidgets/components/widgets/label.py
+4
-2
qfluentwidgets/components/widgets/state_tool_tip.py
qfluentwidgets/components/widgets/state_tool_tip.py
+13
-0
未找到文件。
examples/gallery/app/common/icon.py
浏览文件 @
1874a838
...
...
@@ -9,6 +9,7 @@ class Icon(FluentIconBase, Enum):
HOME
=
"Home"
CHAT
=
"Chat"
MENU
=
"Menu"
SCROLL
=
"Scroll"
LAYOUT
=
"Layout"
GITHUB
=
"Github"
MESSAGE
=
"Message"
...
...
examples/gallery/app/common/translator.py
浏览文件 @
1874a838
...
...
@@ -11,4 +11,5 @@ class Translator(QObject):
self
.
dialogs
=
self
.
tr
(
'Dialogs'
)
self
.
material
=
self
.
tr
(
'Material'
)
self
.
statusInfo
=
self
.
tr
(
'Status & info'
)
self
.
scroll
=
self
.
tr
(
'Scrolling'
)
self
.
layout
=
self
.
tr
(
'Layout'
)
\ No newline at end of file
examples/gallery/app/resource/images/chidanta.jpg
0 → 100644
浏览文件 @
1874a838
326.0 KB
examples/gallery/app/resource/images/chidanta2.jpg
0 → 100644
浏览文件 @
1874a838
240.2 KB
examples/gallery/app/resource/images/icons/Scroll_black.svg
0 → 100644
浏览文件 @
1874a838
<?xml version="1.0" encoding="utf-8"?>
<svg
id=
""
width=
"16"
height=
"16"
style=
"width:16px;height:16px;"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 2048 2048"
enable-background=
"new 0 0 2048 2048"
xml:space=
"preserve"
><path
fill=
"#000000"
transform=
"translate(0, 250)"
d=
"M640 218 l0 1254 q0 26 -19 45 q-19 19 -45 19 q-26 0 -45 -19 q-19 -19 -19 -45 l0 -1254 l-403 403 q-19 19 -45 19 q-26 0 -45 -19 q-19 -19 -19 -45 q0 -26 19 -45 l509 -509 q11 -11 22 -16.5 q11 -5.5 26 -5.5 q15 0 26 5.5 q11 5.5 22 16.5 l509 509 q19 19 19 45 q0 26 -19 45 q-19 19 -45 19 q-26 0 -45 -19 l-403 -403 ZM2048 960 q0 26 -19 45 l-509 509 q-11 11 -21.5 16.5 q-10.5 5.5 -26.5 5.5 q-16 0 -26.5 -5.5 q-10.5 -5.5 -21.5 -16.5 l-509 -509 q-19 -19 -19 -45 q0 -26 19 -45 q19 -19 45 -19 q26 0 45 19 l403 402 l0 -1253 q0 -26 19 -45 q19 -19 45 -19 q26 0 45 19 q19 19 19 45 l0 1253 l403 -402 q19 -19 45 -19 q26 0 45 19 q19 19 19 45 Z"
/></svg>
\ No newline at end of file
examples/gallery/app/resource/images/icons/Scroll_white.svg
0 → 100644
浏览文件 @
1874a838
<?xml version="1.0" encoding="utf-8"?>
<svg
id=
""
width=
"16"
height=
"16"
style=
"width:16px;height:16px;"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 2048 2048"
enable-background=
"new 0 0 2048 2048"
xml:space=
"preserve"
><path
fill=
"#ffffff"
transform=
"translate(0, 250)"
d=
"M640 218 l0 1254 q0 26 -19 45 q-19 19 -45 19 q-26 0 -45 -19 q-19 -19 -19 -45 l0 -1254 l-403 403 q-19 19 -45 19 q-26 0 -45 -19 q-19 -19 -19 -45 q0 -26 19 -45 l509 -509 q11 -11 22 -16.5 q11 -5.5 26 -5.5 q15 0 26 5.5 q11 5.5 22 16.5 l509 509 q19 19 19 45 q0 26 -19 45 q-19 19 -45 19 q-26 0 -45 -19 l-403 -403 ZM2048 960 q0 26 -19 45 l-509 509 q-11 11 -21.5 16.5 q-10.5 5.5 -26.5 5.5 q-16 0 -26.5 -5.5 q-10.5 -5.5 -21.5 -16.5 l-509 -509 q-19 -19 -19 -45 q0 -26 19 -45 q19 -19 45 -19 q26 0 45 19 l403 402 l0 -1253 q0 -26 19 -45 q19 -19 45 -19 q26 0 45 19 q19 19 19 45 l0 1253 l403 -402 q19 -19 45 -19 q26 0 45 19 q19 19 19 45 Z"
/></svg>
\ No newline at end of file
examples/gallery/app/resource/qss/dark/gallery_interface.qss
浏览文件 @
1874a838
...
...
@@ -52,11 +52,15 @@ ExampleCard>#titleLabel {
QScrollBar {
background: transparent;
width: 4px;
margin-top: 32px;
margin-top:
1
32px;
margin-bottom: 0;
padding-right: 2px;
}
#imageViewer QScrollBar {
margin-top: 0px;
}
/*隐藏上箭头*/
QScrollBar::sub-line {
background: transparent;
...
...
examples/gallery/app/resource/qss/light/gallery_interface.qss
浏览文件 @
1874a838
...
...
@@ -49,11 +49,16 @@ ExampleCard > #titleLabel {
QScrollBar {
background: transparent;
width: 4px;
margin-top: 32px;
margin-top:
1
32px;
margin-bottom: 0;
padding-right: 2px;
}
#imageViewer QScrollBar {
margin-top: 0px;
}
/*隐藏上箭头*/
QScrollBar::sub-line {
background: transparent;
...
...
examples/gallery/app/view/basic_input_interface.py
浏览文件 @
1874a838
...
...
@@ -3,7 +3,7 @@ from PyQt5.QtCore import Qt, QSize
from
PyQt5.QtWidgets
import
QWidget
,
QVBoxLayout
,
QButtonGroup
from
PyQt5.QtMultimedia
import
QSound
from
qfluentwidgets
import
(
PushButton
,
ToolButton
,
PrimaryPushButton
,
HyperlinkButton
,
ComboBox
,
RadioButton
,
CheckBox
,
Slider
)
ComboBox
,
RadioButton
,
CheckBox
,
Slider
,
SwitchButton
,
IndicatorPosition
)
from
.gallery_interface
import
GalleryInterface
from
..common.translator
import
Translator
...
...
@@ -103,3 +103,11 @@ class BasicInputInterface(GalleryInterface):
slider
,
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/slider/demo.py'
)
self
.
addExampleCard
(
self
.
tr
(
'A simple switch button'
),
SwitchButton
(
self
.
tr
(
'Off'
),
self
),
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/switch_button/demo.py'
)
examples/gallery/app/view/dialog_interface.py
浏览文件 @
1874a838
# coding:utf-8
from
PyQt5.QtCore
import
Qt
,
pyqtSignal
from
PyQt5.QtGui
import
QPixmap
from
PyQt5.QtWidgets
import
QWidget
from
PyQt5.QtCore
import
Qt
from
qfluentwidgets
import
PushButton
,
Dialog
,
MessageBox
,
ColorDialog
from
..common.translator
import
Translator
...
...
examples/gallery/app/view/gallery_interface.py
浏览文件 @
1874a838
...
...
@@ -67,9 +67,11 @@ class ToolBar(QWidget):
class
ExampleCard
(
QWidget
):
""" Example card """
def
__init__
(
self
,
title
,
widget
:
QWidget
,
sourcePath
,
parent
=
None
):
def
__init__
(
self
,
title
,
widget
:
QWidget
,
sourcePath
,
stretch
=
0
,
parent
=
None
):
super
().
__init__
(
parent
=
parent
)
self
.
widget
=
widget
self
.
stretch
=
stretch
self
.
titleLabel
=
QLabel
(
title
,
self
)
self
.
card
=
QFrame
(
self
)
...
...
@@ -119,7 +121,9 @@ class ExampleCard(QWidget):
self
.
widget
.
setParent
(
self
.
card
)
self
.
topLayout
.
addWidget
(
self
.
widget
)
self
.
topLayout
.
addStretch
(
1
)
if
self
.
stretch
==
0
:
self
.
topLayout
.
addStretch
(
1
)
self
.
widget
.
show
()
self
.
bottomLayout
.
addWidget
(
self
.
sourcePathLabel
,
0
,
Qt
.
AlignLeft
)
...
...
@@ -139,6 +143,18 @@ class GalleryInterface(ScrollArea):
""" Gallery interface """
def
__init__
(
self
,
title
:
str
,
subtitle
:
str
,
parent
=
None
):
"""
Parameters
----------
title: str
The title of gallery
subtitle: str
The subtitle of gallery
parent: QWidget
parent widget
"""
super
().
__init__
(
parent
=
parent
)
self
.
view
=
QWidget
(
self
)
self
.
toolBar
=
ToolBar
(
title
,
subtitle
,
self
)
...
...
@@ -156,9 +172,10 @@ class GalleryInterface(ScrollArea):
self
.
__setQss
()
cfg
.
themeChanged
.
connect
(
self
.
__setQss
)
def
addExampleCard
(
self
,
title
,
widget
,
sourcePath
:
str
):
card
=
ExampleCard
(
title
,
widget
,
sourcePath
,
self
.
view
)
def
addExampleCard
(
self
,
title
,
widget
,
sourcePath
:
str
,
stretch
=
0
):
card
=
ExampleCard
(
title
,
widget
,
sourcePath
,
s
tretch
,
s
elf
.
view
)
self
.
vBoxLayout
.
addWidget
(
card
,
0
,
Qt
.
AlignTop
)
return
card
def
resizeEvent
(
self
,
e
):
super
().
resizeEvent
(
e
)
...
...
examples/gallery/app/view/layout_interface.py
0 → 100644
浏览文件 @
1874a838
# coding:utf-8
from
PyQt5.QtWidgets
import
QWidget
from
qfluentwidgets
import
FlowLayout
,
PushButton
from
.gallery_interface
import
GalleryInterface
from
..common.translator
import
Translator
class
LayoutInterface
(
GalleryInterface
):
""" Layout interface """
def
__init__
(
self
,
parent
=
None
):
t
=
Translator
()
super
().
__init__
(
title
=
t
.
layout
,
subtitle
=
"qfluentwidgets.components.layout"
,
parent
=
parent
)
self
.
addExampleCard
(
self
.
tr
(
'Flow layout without animation'
),
self
.
createWidget
(),
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/flow_layout/demo.py'
,
stretch
=
1
)
self
.
addExampleCard
(
self
.
tr
(
'Flow layout with animation'
),
self
.
createWidget
(
True
),
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/flow_layout/demo.py'
,
stretch
=
1
)
def
createWidget
(
self
,
animation
=
False
):
texts
=
[
self
.
tr
(
'Star Platinum'
),
self
.
tr
(
'Hierophant Green'
),
self
.
tr
(
'Silver Chariot'
),
self
.
tr
(
'Crazy diamond'
),
self
.
tr
(
"Heaven's Door"
),
self
.
tr
(
'Killer Queen'
),
self
.
tr
(
"Gold Experience"
),
self
.
tr
(
'Sticky Fingers'
),
self
.
tr
(
"Sex Pistols"
),
self
.
tr
(
'Dirty Deeds Done Dirt Cheap'
),
]
widget
=
QWidget
()
layout
=
FlowLayout
(
widget
,
animation
)
layout
.
setContentsMargins
(
0
,
0
,
0
,
0
)
layout
.
setVerticalSpacing
(
20
)
layout
.
setHorizontalSpacing
(
10
)
for
text
in
texts
:
layout
.
addWidget
(
PushButton
(
text
))
return
widget
examples/gallery/app/view/main_window.py
浏览文件 @
1874a838
...
...
@@ -9,9 +9,14 @@ from qfluentwidgets import FluentIcon as FIF
from
qframelesswindow
import
FramelessWindow
from
.title_bar
import
CustomTitleBar
from
.setting_interface
import
SettingInterface
,
cfg
from
.basic_input_interface
import
BasicInputInterface
from
.dialog_interface
import
DialogInterface
from
.layout_interface
import
LayoutInterface
from
.material_interface
import
MaterialInterface
from
.menu_interface
import
MenuInterface
from
.scroll_interface
import
ScrollInterface
from
.status_info_interface
import
StatusInfoInterface
from
.setting_interface
import
SettingInterface
,
cfg
from
..components.avatar_widget
import
AvatarWidget
from
..common.icon
import
Icon
...
...
@@ -57,10 +62,20 @@ class MainWindow(FramelessWindow):
# create sub interface
self
.
basicInputInterface
=
BasicInputInterface
(
self
)
self
.
dialogInterface
=
DialogInterface
(
self
)
self
.
layoutInterface
=
LayoutInterface
(
self
)
self
.
menuInterface
=
MenuInterface
(
self
)
self
.
materialInterface
=
MaterialInterface
(
self
)
self
.
scrollInterface
=
ScrollInterface
(
self
)
self
.
statusInfoInterface
=
StatusInfoInterface
(
self
)
self
.
settingInterface
=
SettingInterface
(
self
)
self
.
stackWidget
.
addWidget
(
self
.
basicInputInterface
)
self
.
stackWidget
.
addWidget
(
self
.
dialogInterface
)
self
.
stackWidget
.
addWidget
(
self
.
layoutInterface
)
self
.
stackWidget
.
addWidget
(
self
.
menuInterface
)
self
.
stackWidget
.
addWidget
(
self
.
materialInterface
)
self
.
stackWidget
.
addWidget
(
self
.
scrollInterface
)
self
.
stackWidget
.
addWidget
(
self
.
statusInfoInterface
)
self
.
stackWidget
.
addWidget
(
self
.
settingInterface
)
# initialize layout
...
...
@@ -88,6 +103,11 @@ class MainWindow(FramelessWindow):
def
initNavigation
(
self
):
self
.
basicInputInterface
.
setObjectName
(
'basicInterface'
)
self
.
dialogInterface
.
setObjectName
(
'dialogInterface'
)
self
.
layoutInterface
.
setObjectName
(
'layoutInterface'
)
self
.
menuInterface
.
setObjectName
(
'menuInterface'
)
self
.
materialInterface
.
setObjectName
(
'materialInterface'
)
self
.
statusInfoInterface
.
setObjectName
(
'statusInfoInterface'
)
self
.
scrollInterface
.
setObjectName
(
'scrollInterface'
)
self
.
settingInterface
.
setObjectName
(
'settingsInterface'
)
self
.
navigationInterface
.
addItem
(
...
...
@@ -113,31 +133,38 @@ class MainWindow(FramelessWindow):
position
=
NavigationItemPostion
.
SCROLL
)
self
.
navigationInterface
.
addItem
(
routeKey
=
'Status&info'
,
routeKey
=
self
.
layoutInterface
.
objectName
()
,
icon
=
Icon
.
LAYOUT
,
text
=
self
.
tr
(
'Layout'
),
onClick
=
print
,
onClick
=
lambda
:
self
.
switchTo
(
self
.
layoutInterface
)
,
position
=
NavigationItemPostion
.
SCROLL
)
self
.
navigationInterface
.
addItem
(
routeKey
=
'Menus'
,
routeKey
=
self
.
menuInterface
.
objectName
()
,
icon
=
Icon
.
MENU
,
text
=
self
.
tr
(
'Menus'
),
onClick
=
print
,
onClick
=
lambda
:
self
.
switchTo
(
self
.
menuInterface
)
,
position
=
NavigationItemPostion
.
SCROLL
)
self
.
navigationInterface
.
addItem
(
routeKey
=
'Material'
,
routeKey
=
self
.
materialInterface
.
objectName
()
,
icon
=
FIF
.
PALETTE
,
text
=
self
.
tr
(
'Material'
),
onClick
=
print
,
onClick
=
lambda
:
self
.
switchTo
(
self
.
materialInterface
),
position
=
NavigationItemPostion
.
SCROLL
)
self
.
navigationInterface
.
addItem
(
routeKey
=
self
.
scrollInterface
.
objectName
(),
icon
=
Icon
.
SCROLL
,
text
=
self
.
tr
(
'Scrolling'
),
onClick
=
lambda
:
self
.
switchTo
(
self
.
scrollInterface
),
position
=
NavigationItemPostion
.
SCROLL
)
self
.
navigationInterface
.
addItem
(
routeKey
=
'Layout'
,
routeKey
=
self
.
statusInfoInterface
.
objectName
()
,
icon
=
Icon
.
CHAT
,
text
=
self
.
tr
(
'Status & info'
),
onClick
=
print
,
onClick
=
lambda
:
self
.
switchTo
(
self
.
statusInfoInterface
)
,
position
=
NavigationItemPostion
.
SCROLL
)
...
...
@@ -163,11 +190,13 @@ class MainWindow(FramelessWindow):
self
.
stackWidget
.
currentWidgetChanged
.
connect
(
lambda
w
:
self
.
navigationInterface
.
setCurrentItem
(
w
.
objectName
()))
self
.
navigationInterface
.
setCurrentItem
(
self
.
basicInputInterface
.
objectName
())
self
.
navigationInterface
.
setCurrentItem
(
self
.
basicInputInterface
.
objectName
())
self
.
stackWidget
.
setCurrentIndex
(
0
)
def
initWindow
(
self
):
self
.
resize
(
900
,
700
)
self
.
resize
(
1000
,
780
)
self
.
setMinimumWidth
(
580
)
self
.
setWindowIcon
(
QIcon
(
'app/resource/images/logo.png'
))
self
.
setWindowTitle
(
'PyQt-Fluent-Widgets'
)
self
.
titleBar
.
setAttribute
(
Qt
.
WA_StyledBackground
)
...
...
examples/gallery/app/view/material_interface.py
0 → 100644
浏览文件 @
1874a838
# coding:utf-8
from
PyQt5.QtGui
import
QColor
from
qfluentwidgets.components.widgets.label
import
AcrylicLabel
from
qfluentwidgets
import
FluentIcon
as
FIF
from
.gallery_interface
import
GalleryInterface
from
..common.translator
import
Translator
class
MaterialInterface
(
GalleryInterface
):
""" Material interface """
def
__init__
(
self
,
parent
=
None
):
t
=
Translator
()
super
().
__init__
(
title
=
t
.
menus
,
subtitle
=
'qfluentwidgets.components.widgets'
,
parent
=
parent
)
label
=
AcrylicLabel
(
15
,
QColor
(
105
,
114
,
168
,
102
))
label
.
setImage
(
'app/resource/images/chidanta.jpg'
)
label
.
setMaximumSize
(
787
,
579
)
label
.
setMinimumSize
(
197
,
145
)
self
.
addExampleCard
(
self
.
tr
(
'Acrylic label'
),
label
,
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/acrylic_label/demo.py'
,
stretch
=
1
)
examples/gallery/app/view/menu_interface.py
0 → 100644
浏览文件 @
1874a838
# coding:utf-8
from
PyQt5.QtCore
import
QPoint
from
PyQt5.QtWidgets
import
QAction
from
qfluentwidgets
import
RoundMenu
,
PushButton
from
qfluentwidgets
import
FluentIcon
as
FIF
from
.gallery_interface
import
GalleryInterface
from
..common.translator
import
Translator
class
MenuInterface
(
GalleryInterface
):
""" Menu interface """
def
__init__
(
self
,
parent
=
None
):
t
=
Translator
()
super
().
__init__
(
title
=
t
.
menus
,
subtitle
=
'qfluentwidgets.components.widgets'
,
parent
=
parent
)
button
=
PushButton
(
'Show menu'
)
button
.
clicked
.
connect
(
lambda
:
self
.
createMenu
(
button
.
mapToGlobal
(
QPoint
())
+
QPoint
(
button
.
width
()
+
5
,
-
100
)))
self
.
addExampleCard
(
self
.
tr
(
'Rounded corners menu'
),
button
,
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/menu/demo.py'
)
def
createMenu
(
self
,
pos
):
menu
=
RoundMenu
(
parent
=
self
)
# add actions
menu
.
addAction
(
QAction
(
FIF
.
COPY
.
icon
(),
'Copy'
))
menu
.
addAction
(
QAction
(
FIF
.
CUT
.
icon
(),
'Cut'
))
# add sub menu
submenu
=
RoundMenu
(
"Add to"
,
self
)
submenu
.
setIcon
(
FIF
.
ADD
.
icon
())
submenu
.
addActions
([
QAction
(
FIF
.
VIDEO
.
icon
(),
'Video'
),
QAction
(
FIF
.
MUSIC
.
icon
(),
'Music'
),
])
menu
.
addMenu
(
submenu
)
# add actions
menu
.
addActions
([
QAction
(
FIF
.
PASTE
.
icon
(),
'Paste'
),
QAction
(
FIF
.
CANCEL
.
icon
(),
'Undo'
)
])
# add separator
menu
.
addSeparator
()
menu
.
addAction
(
QAction
(
f
'Select all'
))
# insert actions
menu
.
insertAction
(
menu
.
menuActions
()[
-
1
],
QAction
(
FIF
.
SETTING
.
icon
(),
'Settings'
))
menu
.
insertActions
(
menu
.
menuActions
()[
-
1
],
[
QAction
(
FIF
.
HELP
.
icon
(),
'Help'
),
QAction
(
FIF
.
FEEDBACK
.
icon
(),
'Feedback'
)]
)
# show menu
menu
.
exec
(
pos
,
ani
=
True
)
examples/gallery/app/view/scroll_interface.py
0 → 100644
浏览文件 @
1874a838
# coding:utf-8
from
PyQt5.QtCore
import
Qt
,
QEasingCurve
from
PyQt5.QtGui
import
QPixmap
from
PyQt5.QtWidgets
import
QWidget
,
QLabel
from
qfluentwidgets
import
ScrollArea
,
SmoothScrollArea
from
.gallery_interface
import
GalleryInterface
from
..common.translator
import
Translator
class
ScrollInterface
(
GalleryInterface
):
""" Scroll interface """
def
__init__
(
self
,
parent
=
None
):
t
=
Translator
()
super
().
__init__
(
title
=
t
.
scroll
,
subtitle
=
"qfluentwidgets.components.widgets"
,
parent
=
parent
)
w
=
ScrollArea
()
label
=
QLabel
(
self
)
label
.
setPixmap
(
QPixmap
(
"app/resource/images/chidanta2.jpg"
).
scaled
(
775
,
1229
,
Qt
.
KeepAspectRatio
,
Qt
.
SmoothTransformation
))
w
.
horizontalScrollBar
().
setValue
(
0
)
w
.
setWidget
(
label
)
w
.
setFixedHeight
(
400
)
w
.
setObjectName
(
'imageViewer'
)
self
.
addExampleCard
(
self
.
tr
(
'Smooth scroll area'
),
w
,
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/scroll_area/demo.py'
,
)
examples/gallery/app/view/status_info_interface.py
0 → 100644
浏览文件 @
1874a838
# coding:utf-8
from
PyQt5.QtCore
import
Qt
from
PyQt5.QtGui
import
QPixmap
from
PyQt5.QtWidgets
import
QWidget
,
QLabel
from
qfluentwidgets
import
StateToolTip
,
ToolTipFilter
,
PushButton
from
.gallery_interface
import
GalleryInterface
from
..common.translator
import
Translator
class
StatusInfoInterface
(
GalleryInterface
):
""" Status info interface """
def
__init__
(
self
,
parent
=
None
):
t
=
Translator
()
super
().
__init__
(
title
=
t
.
statusInfo
,
subtitle
=
"qfluentwidgets.components.widgets"
,
parent
=
parent
)
self
.
stateTooltip
=
None
button
=
PushButton
(
'Show StateToolTip'
)
button
.
clicked
.
connect
(
self
.
onStateButtonClicked
)
self
.
addExampleCard
(
self
.
tr
(
'State tool tip'
),
button
,
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/status_tool_tip/demo.py'
)
button
=
PushButton
(
'Button with a simple ToolTip'
)
button
.
installEventFilter
(
ToolTipFilter
(
button
))
button
.
setToolTip
(
'Simple ToolTip'
)
self
.
addExampleCard
(
self
.
tr
(
'State tool tip'
),
button
,
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/tool_tip/demo.py'
)
label
=
QLabel
()
label
.
setPixmap
(
QPixmap
(
'app/resource/images/kunkun.png'
).
scaled
(
200
,
200
,
Qt
.
KeepAspectRatio
,
Qt
.
SmoothTransformation
))
label
.
installEventFilter
(
ToolTipFilter
(
label
,
showDelay
=
500
))
label
.
setToolTip
(
self
.
tr
(
'Label with a ToolTip'
))
label
.
setToolTipDuration
(
2000
)
label
.
setFixedSize
(
200
,
200
)
self
.
addExampleCard
(
self
.
tr
(
'A label with a ToolTip'
),
label
,
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/tool_tip/demo.py'
)
def
onStateButtonClicked
(
self
):
if
self
.
stateTooltip
:
self
.
stateTooltip
.
setContent
(
'The model training is complete! 😆'
)
self
.
stateTooltip
.
setState
(
True
)
self
.
stateTooltip
=
None
else
:
self
.
stateTooltip
=
StateToolTip
(
'Training model'
,
'Please wait patiently'
,
self
.
window
())
self
.
sender
().
setText
(
self
.
tr
(
'Hide state tool tip'
))
self
.
stateTooltip
.
move
(
self
.
stateTooltip
.
getSuitablePos
())
self
.
stateTooltip
.
show
()
qfluentwidgets/components/navigation/navigation_panel.py
浏览文件 @
1874a838
...
...
@@ -36,6 +36,9 @@ class NavigationPanel(QFrame):
def
__init__
(
self
,
parent
=
None
,
isMinimalEnabled
=
False
):
super
().
__init__
(
parent
=
parent
)
self
.
_parent
=
parent
# type: QWidget
self
.
_isMenuButtonVisible
=
True
self
.
_isReturnButtonVisible
=
False
self
.
scrollArea
=
ScrollArea
(
self
)
self
.
scrollWidget
=
QWidget
()
...
...
@@ -192,10 +195,12 @@ class NavigationPanel(QFrame):
def
setMenuButtonVisible
(
self
,
isVisible
:
bool
):
""" set whether the menu button is visible """
self
.
_isMenuButtonVisible
=
isVisible
self
.
menuButton
.
setVisible
(
isVisible
)
def
setReturnButtonVisible
(
self
,
isVisible
:
bool
):
""" set whether the menu button is visible """
self
.
_isReturnButtonVisible
=
isVisible
self
.
returnButton
.
setVisible
(
isVisible
)
def
setExpandWidth
(
self
,
width
:
int
):
...
...
@@ -298,7 +303,7 @@ class NavigationPanel(QFrame):
if
w
<
1008
and
self
.
displayMode
==
NavigationDisplayMode
.
EXPAND
:
self
.
collapse
()
elif
w
>=
1008
and
self
.
displayMode
==
NavigationDisplayMode
.
COMPACT
and
\
not
self
.
menuButton
.
isVisible
()
:
not
self
.
_isMenuButtonVisible
:
self
.
expand
()
return
super
().
eventFilter
(
obj
,
e
)
...
...
qfluentwidgets/components/widgets/label.py
浏览文件 @
1874a838
...
...
@@ -10,6 +10,8 @@ try:
except
ImportError
as
e
:
warnings
.
warn
(
'`AcrylicLabel` is not supported in current qfluentwidgets, use `pip install PyQt-Fluent-Widgets[full]` to enable it.'
)
def
gaussianBlur
(
imagePath
,
blurRadius
=
18
,
brightFactor
=
1
,
blurPicSize
=
None
):
return
QPixmap
(
imagePath
)
class
BlurCoverThread
(
QThread
):
...
...
@@ -21,7 +23,7 @@ class BlurCoverThread(QThread):
super
().
__init__
(
parent
)
self
.
imagePath
=
""
self
.
blurRadius
=
7
self
.
maxSize
=
(
450
,
450
)
self
.
maxSize
=
None
def
run
(
self
):
if
not
self
.
imagePath
:
...
...
@@ -141,6 +143,6 @@ class AcrylicLabel(QLabel):
super
().
resizeEvent
(
e
)
self
.
acrylicTextureLabel
.
resize
(
self
.
size
())
if
not
self
.
blurPixmap
.
isNull
():
if
not
self
.
blurPixmap
.
isNull
()
and
self
.
blurPixmap
.
size
()
!=
self
.
size
()
:
self
.
setPixmap
(
self
.
blurPixmap
.
scaled
(
self
.
size
(),
Qt
.
KeepAspectRatioByExpanding
,
Qt
.
SmoothTransformation
))
qfluentwidgets/components/widgets/state_tool_tip.py
浏览文件 @
1874a838
...
...
@@ -129,6 +129,19 @@ class StateToolTip(QWidget):
self
.
rotateAngle
=
(
self
.
rotateAngle
+
self
.
deltaAngle
)
%
360
self
.
update
()
def
getSuitablePos
(
self
):
""" get suitable position in main window """
for
i
in
range
(
10
):
dy
=
i
*
(
self
.
height
()
+
16
)
pos
=
QPoint
(
self
.
window
().
width
()
-
self
.
width
()
-
24
,
50
+
dy
)
widget
=
self
.
window
().
childAt
(
pos
+
QPoint
(
2
,
2
))
if
isinstance
(
widget
,
(
StateToolTip
,
ToastToolTip
)):
pos
+=
QPoint
(
0
,
self
.
height
()
+
16
)
else
:
break
return
pos
def
paintEvent
(
self
,
e
):
""" paint state tooltip """
super
().
paintEvent
(
e
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录