Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
8007717b
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看板
提交
8007717b
编写于
7月 21, 2022
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
调整颜色选取器的阴影
上级
df9c2994
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
13 deletion
+36
-13
screenshot/color_picker.gif
screenshot/color_picker.gif
+0
-0
widgets/color_picker/color_picker.py
widgets/color_picker/color_picker.py
+29
-11
widgets/color_picker/demo.py
widgets/color_picker/demo.py
+3
-2
widgets/color_picker/resource/color_picker.qss
widgets/color_picker/resource/color_picker.qss
+4
-0
未找到文件。
screenshot/color_picker.gif
查看替换文件 @
df9c2994
浏览文件 @
8007717b
150.8 KB
|
W:
|
H:
126.2 KB
|
W:
|
H:
2-up
Swipe
Onion skin
widgets/color_picker/color_picker.py
浏览文件 @
8007717b
...
...
@@ -4,8 +4,9 @@ import math
from
PyQt5.QtCore
import
QPoint
,
Qt
,
pyqtSignal
from
PyQt5.QtGui
import
QColor
,
QMouseEvent
,
QPainter
,
QPen
,
QPixmap
from
PyQt5.QtWidgets
import
(
QHBoxLayout
,
QLabel
,
QPushButton
,
QSlider
,
QToolButton
,
QVBoxLayout
,
QWidget
)
from
PyQt5.QtWidgets
import
(
QFrame
,
QGraphicsDropShadowEffect
,
QHBoxLayout
,
QLabel
,
QPushButton
,
QSlider
,
QToolButton
,
QVBoxLayout
,
QWidget
)
class
DefaultColorPanel
(
QWidget
):
...
...
@@ -232,17 +233,31 @@ class ColorPickerPanel(QWidget):
def
__init__
(
self
,
startColor
=
QColor
(
255
,
0
,
0
),
parent
=
None
):
super
().
__init__
(
parent
=
parent
)
self
.
setFixedHeight
(
480
)
self
.
setWindowFlags
(
Qt
.
Popup
)
self
.
setWindowFlags
(
Qt
.
Popup
|
Qt
.
NoDropShadowWindowHint
|
Qt
.
FramelessWindowHint
)
self
.
setAttribute
(
Qt
.
WA_TranslucentBackground
)
with
open
(
'resource/color_picker.qss'
,
encoding
=
'utf-8'
)
as
f
:
self
.
setStyleSheet
(
f
.
read
())
self
.
vBoxLayout
=
QVBoxLayout
(
self
)
self
.
sliderWidget
=
SliderWidget
(
self
)
self
.
colorCircle
=
ColorCircle
(
startColor
,
self
)
self
.
defaultColorPanel
=
DefaultColorPanel
(
self
)
self
.
hBoxLayout
=
QHBoxLayout
(
self
)
self
.
container
=
QFrame
(
self
)
self
.
vBoxLayout
=
QVBoxLayout
(
self
.
container
)
self
.
sliderWidget
=
SliderWidget
()
self
.
colorCircle
=
ColorCircle
(
startColor
)
self
.
defaultColorPanel
=
DefaultColorPanel
()
# add shadow
self
.
shadowEffect
=
QGraphicsDropShadowEffect
(
self
)
self
.
shadowEffect
.
setBlurRadius
(
32
)
self
.
shadowEffect
.
setColor
(
QColor
(
0
,
0
,
0
,
70
))
self
.
shadowEffect
.
setOffset
(
0
,
5
)
self
.
container
.
setGraphicsEffect
(
self
.
shadowEffect
)
# initialize layout
self
.
hBoxLayout
.
setContentsMargins
(
20
,
15
,
20
,
30
)
self
.
hBoxLayout
.
addWidget
(
self
.
container
)
self
.
vBoxLayout
.
setContentsMargins
(
15
,
15
,
15
,
10
)
self
.
vBoxLayout
.
addWidget
(
self
.
colorCircle
)
self
.
vBoxLayout
.
addWidget
(
self
.
sliderWidget
)
self
.
vBoxLayout
.
addWidget
(
self
.
defaultColorPanel
)
...
...
@@ -265,6 +280,8 @@ class ColorPickerPanel(QWidget):
class
ColorPicker
(
QWidget
):
""" Color picker """
colorChanged
=
pyqtSignal
(
QColor
)
def
__init__
(
self
,
color
:
QColor
,
parent
=
None
):
super
().
__init__
(
parent
=
parent
)
self
.
setFixedSize
(
40
,
30
)
...
...
@@ -274,18 +291,19 @@ class ColorPicker(QWidget):
self
.
colorPickerPanel
.
hide
()
self
.
setCursor
(
Qt
.
PointingHandCursor
)
def
__onColorChanged
(
self
,
color
):
def
__onColorChanged
(
self
,
color
:
QColor
):
self
.
color
=
color
self
.
update
()
self
.
colorChanged
.
emit
(
color
)
def
mousePressEvent
(
self
,
e
):
pos
=
self
.
mapToGlobal
(
QPoint
())
self
.
colorPickerPanel
.
move
(
pos
+
QPoint
(
50
,
0
))
self
.
colorPickerPanel
.
move
(
pos
+
QPoint
(
50
,
-
2
0
))
self
.
colorPickerPanel
.
show
()
def
paintEvent
(
self
,
e
):
painter
=
QPainter
(
self
)
painter
.
setRenderHints
(
QPainter
.
Antialiasing
)
painter
.
setPen
(
Q
Pen
(
QColor
(
0
,
0
,
0
,
0.3
),
2
)
)
painter
.
setPen
(
Q
t
.
NoPen
)
painter
.
setBrush
(
self
.
color
)
painter
.
drawRoundedRect
(
self
.
rect
(),
5
,
5
)
widgets/color_picker/demo.py
浏览文件 @
8007717b
...
...
@@ -10,9 +10,10 @@ class Demo(QWidget):
def
__init__
(
self
):
super
().
__init__
()
self
.
resize
(
500
,
5
00
)
self
.
resize
(
500
,
6
00
)
self
.
colorPicker
=
ColorPicker
(
QColor
(
0
,
153
,
188
),
self
)
self
.
colorPicker
.
move
(
200
,
200
)
self
.
colorPicker
.
move
(
50
,
50
)
self
.
setStyleSheet
(
"Demo{background:white}"
)
if
__name__
==
'__main__'
:
...
...
widgets/color_picker/resource/color_picker.qss
浏览文件 @
8007717b
...
...
@@ -3,6 +3,10 @@ QWidget {
/* background-color: rgb(17, 34, 49); */
}
QFrame{
border-radius: 8px;
}
QPushButton{
margin: 0;
border: 0px solid transparent;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录