Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
2eb09a7a
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看板
提交
2eb09a7a
编写于
8月 05, 2023
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加系统托盘菜单
上级
60605848
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
77333 addition
and
77310 deletion
+77333
-77310
examples/system_tray_menu/demo.py
examples/system_tray_menu/demo.py
+81
-0
qfluentwidgets/__init__.py
qfluentwidgets/__init__.py
+1
-1
qfluentwidgets/_rc/qss/dark/menu.qss
qfluentwidgets/_rc/qss/dark/menu.qss
+3
-35
qfluentwidgets/_rc/qss/light/menu.qss
qfluentwidgets/_rc/qss/light/menu.qss
+3
-34
qfluentwidgets/_rc/resource.py
qfluentwidgets/_rc/resource.py
+77213
-77237
qfluentwidgets/components/widgets/__init__.py
qfluentwidgets/components/widgets/__init__.py
+2
-1
qfluentwidgets/components/widgets/menu.py
qfluentwidgets/components/widgets/menu.py
+29
-1
setup.py
setup.py
+1
-1
未找到文件。
examples/system_tray_menu/demo.py
0 → 100644
浏览文件 @
2eb09a7a
# coding:utf-8
import
sys
from
PyQt5.QtCore
import
Qt
from
PyQt5.QtGui
import
QIcon
from
PyQt5.QtWidgets
import
QApplication
,
QWidget
,
QSystemTrayIcon
,
QHBoxLayout
,
QLabel
from
qfluentwidgets
import
Action
,
SystemTrayMenu
,
MessageBox
,
setTheme
,
Theme
class
SystemTrayIcon
(
QSystemTrayIcon
):
def
__init__
(
self
,
parent
=
None
):
super
().
__init__
(
parent
=
parent
)
self
.
setIcon
(
parent
.
windowIcon
())
self
.
setToolTip
(
'硝子酱一级棒卡哇伊🥰'
)
self
.
menu
=
SystemTrayMenu
(
parent
=
parent
)
self
.
menu
.
addActions
([
Action
(
'🎤 唱'
),
Action
(
'🕺 跳'
),
Action
(
'🤘🏼 RAP'
),
Action
(
'🎶 Music'
),
Action
(
'🏀 篮球'
,
triggered
=
self
.
ikun
),
])
self
.
setContextMenu
(
self
.
menu
)
def
ikun
(
self
):
content
=
"""巅峰产生虚伪的拥护,黄昏见证真正的使徒 🏀
⠀⠰⢷⢿⠄
⠀⠀⠀⠀⠀⣼⣷⣄
⠀⠀⣤⣿⣇⣿⣿⣧⣿⡄
⢴⠾⠋⠀⠀⠻⣿⣷⣿⣿⡀
⠀⢀⣿⣿⡿⢿⠈⣿
⠀⠀⠀⢠⣿⡿⠁⠀⡊⠀⠙
⠀⠀⠀⢿⣿⠀⠀⠹⣿
⠀⠀⠀⠀⠹⣷⡀⠀⣿⡄
⠀⠀⠀⠀⣀⣼⣿⠀⢈⣧
"""
w
=
MessageBox
(
title
=
'坤家军!集合!'
,
content
=
content
,
parent
=
self
.
parent
()
)
w
.
yesButton
.
setText
(
'献出心脏'
)
w
.
cancelButton
.
setText
(
'你干嘛~'
)
w
.
exec
()
class
Demo
(
QWidget
):
def
__init__
(
self
):
super
().
__init__
()
# setTheme(Theme.DARK)
self
.
setLayout
(
QHBoxLayout
())
self
.
label
=
QLabel
(
'Right-click system tray icon'
,
self
)
self
.
label
.
setAlignment
(
Qt
.
AlignCenter
)
self
.
layout
().
addWidget
(
self
.
label
)
self
.
resize
(
500
,
500
)
self
.
setStyleSheet
(
'Demo{background: white} QLabel{font-size: 20px}'
)
self
.
setWindowIcon
(
QIcon
(
':/qfluentwidgets/images/logo.png'
))
self
.
systemTrayIcon
=
SystemTrayIcon
(
self
)
self
.
systemTrayIcon
.
show
()
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
qfluentwidgets/__init__.py
浏览文件 @
2eb09a7a
...
@@ -12,7 +12,7 @@ Examples are available at https://github.com/zhiyiYo/PyQt-Fluent-Widgets/tree/ma
...
@@ -12,7 +12,7 @@ Examples are available at https://github.com/zhiyiYo/PyQt-Fluent-Widgets/tree/ma
:license: GPLv3, see LICENSE for more details.
:license: GPLv3, see LICENSE for more details.
"""
"""
__version__
=
"1.0.
3
"
__version__
=
"1.0.
4
"
from
.components
import
*
from
.components
import
*
from
.common
import
*
from
.common
import
*
...
...
qfluentwidgets/_rc/qss/dark/menu.qss
浏览文件 @
2eb09a7a
/*设置菜单样式*/
RoundMenu {
QMenu {
background-color: transparent;
background-color: rgb(43, 43, 43);
border: none;
font: 14px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
padding: 4px 0px 4px 0px;
border: 1px solid rgb(34, 34, 34);
color: white;
}
QMenu::right-arrow {
width: 13px;
height: 13px;
right: 13px;
border-image: url(:/qfluentwidgets/images/menu/ChevronRight_white.svg);
}
QMenu::separator {
height: 1px;
background: rgba(255, 255, 255, 104);
margin-right: 13px;
margin-top: 4px;
margin-bottom: 4px;
margin-left: 10px;
}
QMenu::item {
padding: 6px 10px 6px 10px;
}
QMenu::item:selected {
border-width: 1px;
border-color: rgb(33, 33, 33);
background: rgb(64, 64, 64);
color: white;
}
}
MenuActionListWidget {
MenuActionListWidget {
border: 1px solid rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 9px;
border-radius: 9px;
...
...
qfluentwidgets/_rc/qss/light/menu.qss
浏览文件 @
2eb09a7a
QMenu {
RoundMenu {
background-color: rgb(232, 232, 232);
background-color: transparent;
font: 14px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
border: none;
padding: 4px 0px 4px 0px;
border: 1px solid rgb(200, 200, 200);
}
QMenu::right-arrow {
width: 13px;
height: 13px;
right: 13px;
border-image: url(:/qfluentwidgets/images/menu/ChevronRight_black.svg);
}
QMenu::separator {
height: 1px;
background: rgba(0, 0, 0, 104);
margin-right: 13px;
margin-top: 4px;
margin-bottom: 4px;
margin-left: 10px;
}
QMenu::item {
padding: 6px 10px 6px 10px;
}
QMenu::item:selected {
border-width: 1px;
border-color: rgb(212, 212, 212);
background: rgba(0, 0, 0, 25);
color: black;
}
}
MenuActionListWidget {
MenuActionListWidget {
border: 1px solid rgba(0, 0, 0, 0.1);
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: 9px;
border-radius: 9px;
...
...
qfluentwidgets/_rc/resource.py
浏览文件 @
2eb09a7a
此差异已折叠。
点击以展开。
qfluentwidgets/components/widgets/__init__.py
浏览文件 @
2eb09a7a
...
@@ -15,7 +15,8 @@ from .label import (PixmapLabel, CaptionLabel, StrongBodyLabel, BodyLabel, Subti
...
@@ -15,7 +15,8 @@ from .label import (PixmapLabel, CaptionLabel, StrongBodyLabel, BodyLabel, Subti
LargeTitleLabel
,
DisplayLabel
,
FluentLabelBase
,
ImageLabel
)
LargeTitleLabel
,
DisplayLabel
,
FluentLabelBase
,
ImageLabel
)
from
.list_view
import
ListWidget
,
ListView
,
ListItemDelegate
from
.list_view
import
ListWidget
,
ListView
,
ListItemDelegate
from
.menu
import
(
DWMMenu
,
LineEditMenu
,
RoundMenu
,
MenuAnimationManager
,
MenuAnimationType
,
IndicatorMenuItemDelegate
,
from
.menu
import
(
DWMMenu
,
LineEditMenu
,
RoundMenu
,
MenuAnimationManager
,
MenuAnimationType
,
IndicatorMenuItemDelegate
,
MenuItemDelegate
,
ShortcutMenuItemDelegate
,
CheckableMenu
,
MenuIndicatorType
)
MenuItemDelegate
,
ShortcutMenuItemDelegate
,
CheckableMenu
,
MenuIndicatorType
,
SystemTrayMenu
,
CheckableSystemTrayMenu
)
from
.info_bar
import
InfoBar
,
InfoBarIcon
,
InfoBarPosition
,
InfoBarManager
from
.info_bar
import
InfoBar
,
InfoBarIcon
,
InfoBarPosition
,
InfoBarManager
from
.info_badge
import
InfoBadge
,
InfoLevel
,
DotInfoBadge
,
IconInfoBadge
,
InfoBadgePosition
,
InfoBadgeManager
from
.info_badge
import
InfoBadge
,
InfoLevel
,
DotInfoBadge
,
IconInfoBadge
,
InfoBadgePosition
,
InfoBadgeManager
from
.scroll_area
import
SingleDirectionScrollArea
,
SmoothMode
,
SmoothScrollArea
,
ScrollArea
from
.scroll_area
import
SingleDirectionScrollArea
,
SmoothMode
,
SmoothScrollArea
,
ScrollArea
...
...
qfluentwidgets/components/widgets/menu.py
浏览文件 @
2eb09a7a
...
@@ -246,7 +246,7 @@ class MenuActionListWidget(QListWidget):
...
@@ -246,7 +246,7 @@ class MenuActionListWidget(QListWidget):
return
sum
(
self
.
item
(
i
).
sizeHint
().
height
()
for
i
in
range
(
self
.
count
()))
return
sum
(
self
.
item
(
i
).
sizeHint
().
height
()
for
i
in
range
(
self
.
count
()))
class
RoundMenu
(
Q
Widget
):
class
RoundMenu
(
Q
Menu
):
""" Round corner menu """
""" Round corner menu """
closedSignal
=
pyqtSignal
()
closedSignal
=
pyqtSignal
()
...
@@ -690,6 +690,18 @@ class RoundMenu(QWidget):
...
@@ -690,6 +690,18 @@ class RoundMenu(QWidget):
"""
"""
self
.
exec
(
pos
,
ani
,
aniType
)
self
.
exec
(
pos
,
ani
,
aniType
)
def
adjustPosition
(
self
):
m
=
self
.
layout
().
contentsMargins
()
rect
=
QApplication
.
screenAt
(
QCursor
.
pos
()).
availableGeometry
()
w
,
h
=
self
.
layout
().
sizeHint
().
width
()
+
5
,
self
.
layout
().
sizeHint
().
height
()
x
=
min
(
self
.
x
()
-
m
.
left
(),
rect
.
right
()
-
w
)
y
=
self
.
y
()
if
y
>
rect
.
bottom
()
-
h
:
y
=
self
.
y
()
-
h
+
m
.
bottom
()
self
.
move
(
x
,
y
)
class
MenuAnimationManager
(
QObject
):
class
MenuAnimationManager
(
QObject
):
""" Menu animation manager """
""" Menu animation manager """
...
@@ -1126,3 +1138,19 @@ class CheckableMenu(RoundMenu):
...
@@ -1126,3 +1138,19 @@ class CheckableMenu(RoundMenu):
def
_adjustItemText
(
self
,
item
:
QListWidgetItem
,
action
:
QAction
):
def
_adjustItemText
(
self
,
item
:
QListWidgetItem
,
action
:
QAction
):
w
=
super
().
_adjustItemText
(
item
,
action
)
w
=
super
().
_adjustItemText
(
item
,
action
)
item
.
setSizeHint
(
QSize
(
w
+
26
,
self
.
itemHeight
))
item
.
setSizeHint
(
QSize
(
w
+
26
,
self
.
itemHeight
))
class
SystemTrayMenu
(
RoundMenu
):
""" System tray menu """
def
showEvent
(
self
,
e
):
super
().
showEvent
(
e
)
self
.
adjustPosition
()
class
CheckableSystemTrayMenu
(
CheckableMenu
):
""" Checkable system tray menu """
def
showEvent
(
self
,
e
):
super
().
showEvent
(
e
)
self
.
adjustPosition
()
setup.py
浏览文件 @
2eb09a7a
...
@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
...
@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools
.
setup
(
setuptools
.
setup
(
name
=
"PyQt-Fluent-Widgets"
,
name
=
"PyQt-Fluent-Widgets"
,
version
=
"1.0.
3
"
,
version
=
"1.0.
4
"
,
keywords
=
"pyqt fluent widgets"
,
keywords
=
"pyqt fluent widgets"
,
author
=
"zhiyiYo"
,
author
=
"zhiyiYo"
,
author_email
=
"shokokawaii@outlook.com"
,
author_email
=
"shokokawaii@outlook.com"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录