Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
c00d5d50
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看板
提交
c00d5d50
编写于
5月 23, 2022
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加工具提示
上级
e857bc41
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
211 addition
and
1 deletion
+211
-1
README.md
README.md
+14
-1
screenshot/ToolTip.gif
screenshot/ToolTip.gif
+0
-0
widgets/tool_tip/demo.py
widgets/tool_tip/demo.py
+69
-0
widgets/tool_tip/resource/demo.qss
widgets/tool_tip/resource/demo.qss
+25
-0
widgets/tool_tip/resource/tooltip.qss
widgets/tool_tip/resource/tooltip.qss
+24
-0
widgets/tool_tip/tool_tip.py
widgets/tool_tip/tool_tip.py
+79
-0
未找到文件。
README.md
浏览文件 @
c00d5d50
...
...
@@ -124,6 +124,19 @@ A collection of commonly used widgets.
<img
src=
"screenshot/state_tooltip.gif"
/>
</td>
</tr>
<tr>
<td>
Tooltip
</td>
<td>
<code>
Tooltip
</code>
</td>
</tr>
<tr>
<td
colspan=
"2"
align=
"center"
>
<img
src=
"screenshot/ToolTip.gif"
/>
</td>
</tr>
<tr>
<td>
Flow Layout
...
...
@@ -147,7 +160,7 @@ A collection of commonly used widgets.
</tr>
<tr>
<td
colspan=
"2"
align=
"center"
>
<img
src=
"screenshot/acrylic_label.png"
/>
<img
src=
"screenshot/acrylic_label.png"
style=
"width:70%"
/>
</td>
</tr>
<tr>
...
...
screenshot/ToolTip.gif
0 → 100644
浏览文件 @
c00d5d50
25.7 KB
widgets/tool_tip/demo.py
0 → 100644
浏览文件 @
c00d5d50
# coding:utf-8
import
sys
from
PyQt5.QtCore
import
QEvent
,
QPoint
from
PyQt5.QtWidgets
import
QApplication
,
QWidget
,
QPushButton
,
QHBoxLayout
from
tool_tip
import
ToolTip
class
Demo
(
QWidget
):
def
__init__
(
self
):
super
().
__init__
()
self
.
hBox
=
QHBoxLayout
(
self
)
self
.
button1
=
QPushButton
(
'キラキラ'
,
self
)
self
.
button2
=
QPushButton
(
'食べた愛'
,
self
)
self
.
_toolTip
=
ToolTip
(
parent
=
self
)
# self._tooltip.setDarkTheme(True)
self
.
button1
.
setToolTip
(
'aiko - キラキラ ✨'
)
self
.
button2
.
setToolTip
(
'aiko - 食べた愛 🥰'
)
self
.
button1
.
setToolTipDuration
(
1000
)
self
.
button2
.
setToolTipDuration
(
5000
)
self
.
button1
.
installEventFilter
(
self
)
self
.
button2
.
installEventFilter
(
self
)
self
.
hBox
.
setContentsMargins
(
30
,
30
,
30
,
30
)
self
.
hBox
.
setSpacing
(
20
)
self
.
hBox
.
addWidget
(
self
.
button1
)
self
.
hBox
.
addWidget
(
self
.
button2
)
self
.
resize
(
600
,
300
)
self
.
_toolTip
.
hide
()
with
open
(
'resource/demo.qss'
,
encoding
=
'utf-8'
)
as
f
:
self
.
setStyleSheet
(
f
.
read
())
def
eventFilter
(
self
,
obj
,
e
:
QEvent
):
if
obj
is
self
:
return
super
().
eventFilter
(
obj
,
e
)
tip
=
self
.
_toolTip
if
e
.
type
()
==
QEvent
.
Enter
:
tip
.
setText
(
obj
.
toolTip
())
tip
.
setDuration
(
obj
.
toolTipDuration
())
pos
=
obj
.
mapTo
(
self
,
QPoint
(
0
,
0
))
x
=
pos
.
x
()
+
obj
.
width
()
//
2
-
tip
.
width
()
//
2
y
=
pos
.
y
()
-
5
-
tip
.
height
()
# adjust postion to prevent tooltips from appearing outside the window
x
=
min
(
max
(
5
,
x
),
self
.
width
()
-
tip
.
width
()
-
5
)
y
=
min
(
max
(
5
,
y
),
self
.
height
()
-
tip
.
height
()
-
5
)
tip
.
move
(
x
,
y
)
tip
.
show
()
elif
e
.
type
()
==
QEvent
.
Leave
:
tip
.
hide
()
elif
e
.
type
()
==
QEvent
.
ToolTip
:
return
True
return
super
().
eventFilter
(
obj
,
e
)
if
__name__
==
'__main__'
:
app
=
QApplication
(
sys
.
argv
)
w
=
Demo
()
w
.
show
()
app
.
exec_
()
widgets/tool_tip/resource/demo.qss
0 → 100644
浏览文件 @
c00d5d50
QWidget{
background-color: white;
}
QPushButton {
background-color: rgb(204, 204, 204);
padding: 10px 64px 10px 64px;
font: 19px 'Microsoft YaHei';
border: transparent;
border-radius: 4px;
/* height: 40px; */
}
QPushButton:pressed:hover {
background-color: rgb(153, 153, 153);
}
QPushButton:hover {
background-color: rgb(230, 230, 230);
}
QPushButton:disabled {
background-color: rgb(204, 204, 204);
color: rgb(122, 122, 122);
}
\ No newline at end of file
widgets/tool_tip/resource/tooltip.qss
0 → 100644
浏览文件 @
c00d5d50
ToolTip[dark="false"] {
border: 1px solid rgba(0, 0, 0, 0.06);
border-radius: 5px;
background-color: rgb(243, 243, 243);
}
ToolTip[dark="true"] {
border: 1px solid rgb(28, 28, 28);
border-radius: 5px;
background-color: rgb(43, 43, 43);
}
QLabel {
background-color: transparent;
font: 15px 'Segoe UI', 'Microsoft YaHei';
}
QLabel[dark="false"] {
color: black;
}
QLabel[dark="true"] {
color: white;
}
\ No newline at end of file
widgets/tool_tip/tool_tip.py
0 → 100644
浏览文件 @
c00d5d50
# coding:utf-8
from
PyQt5.QtCore
import
QFile
,
QPropertyAnimation
,
QTimer
,
Qt
from
PyQt5.QtGui
import
QColor
from
PyQt5.QtWidgets
import
(
QApplication
,
QFrame
,
QGraphicsDropShadowEffect
,
QHBoxLayout
,
QLabel
)
class
ToolTip
(
QFrame
):
def
__init__
(
self
,
text
=
''
,
parent
=
None
):
super
().
__init__
(
parent
=
parent
)
self
.
__text
=
text
self
.
__duration
=
1000
self
.
timer
=
QTimer
(
self
)
self
.
hBox
=
QHBoxLayout
(
self
)
self
.
label
=
QLabel
(
text
,
self
)
self
.
ani
=
QPropertyAnimation
(
self
,
b
'windowOpacity'
,
self
)
# set layout
self
.
hBox
.
addWidget
(
self
.
label
)
self
.
hBox
.
setContentsMargins
(
10
,
7
,
10
,
7
)
# add shadow
self
.
shadowEffect
=
QGraphicsDropShadowEffect
(
self
)
self
.
shadowEffect
.
setBlurRadius
(
32
)
self
.
shadowEffect
.
setColor
(
QColor
(
0
,
0
,
0
,
60
))
self
.
shadowEffect
.
setOffset
(
0
,
5
)
self
.
setGraphicsEffect
(
self
.
shadowEffect
)
self
.
timer
.
setSingleShot
(
True
)
self
.
timer
.
timeout
.
connect
(
self
.
hide
)
# set style
self
.
setAttribute
(
Qt
.
WA_StyledBackground
)
self
.
setDarkTheme
(
False
)
self
.
__setQss
()
def
text
(
self
):
return
self
.
__text
def
setText
(
self
,
text
:
str
):
""" set text on tooltip """
self
.
__text
=
text
self
.
label
.
setText
(
text
)
self
.
label
.
adjustSize
()
self
.
adjustSize
()
def
duration
(
self
):
return
self
.
__duration
def
setDuration
(
self
,
duration
:
int
):
""" set tooltip duration in milliseconds """
self
.
__duration
=
abs
(
duration
)
def
__setQss
(
self
):
""" set style sheet """
f
=
QFile
(
"resource/tooltip.qss"
)
f
.
open
(
QFile
.
ReadOnly
)
self
.
setStyleSheet
(
str
(
f
.
readAll
(),
encoding
=
'utf-8'
))
f
.
close
()
self
.
label
.
adjustSize
()
self
.
adjustSize
()
def
setDarkTheme
(
self
,
dark
=
False
):
""" set dark theme """
dark
=
'true'
if
dark
else
'false'
self
.
setProperty
(
'dark'
,
dark
)
self
.
label
.
setProperty
(
'dark'
,
dark
)
self
.
setStyle
(
QApplication
.
style
())
def
showEvent
(
self
,
e
):
self
.
timer
.
stop
()
self
.
timer
.
start
(
self
.
__duration
)
super
().
showEvent
(
e
)
def
hideEvent
(
self
,
e
):
self
.
timer
.
stop
()
super
().
hideEvent
(
e
)
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录