Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
03ad7b99
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看板
提交
03ad7b99
编写于
4月 28, 2023
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复表格组件无法多选的问题
上级
93700c4f
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
54232 addition
and
54223 deletion
+54232
-54223
examples/table_view/demo.py
examples/table_view/demo.py
+3
-2
qfluentwidgets/__init__.py
qfluentwidgets/__init__.py
+1
-1
qfluentwidgets/_rc/qss/dark/table_view.qss
qfluentwidgets/_rc/qss/dark/table_view.qss
+1
-0
qfluentwidgets/_rc/qss/light/table_view.qss
qfluentwidgets/_rc/qss/light/table_view.qss
+1
-0
qfluentwidgets/_rc/resource.py
qfluentwidgets/_rc/resource.py
+54209
-54207
qfluentwidgets/components/widgets/table_view.py
qfluentwidgets/components/widgets/table_view.py
+16
-12
setup.py
setup.py
+1
-1
未找到文件。
examples/table_view/demo.py
浏览文件 @
03ad7b99
...
...
@@ -2,7 +2,7 @@
import
sys
from
PyQt5.QtCore
import
Qt
from
PyQt5.QtWidgets
import
QApplication
,
Q
HeaderView
,
QTableWidgetItem
,
QWidget
,
QHBoxLayout
from
PyQt5.QtWidgets
import
QApplication
,
Q
TableWidget
,
QTableWidgetItem
,
QWidget
,
QHBoxLayout
from
qfluentwidgets
import
TableWidget
,
setTheme
,
Theme
,
TableView
...
...
@@ -58,13 +58,14 @@ class Demo(QWidget):
self
.
tableView
.
verticalHeader
().
hide
()
self
.
tableView
.
setHorizontalHeaderLabels
([
'标题'
,
'艺人'
,
'专辑'
,
'年份'
,
'时长'
])
self
.
tableView
.
resizeColumnsToContents
()
# self.tableView.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
# self.tableView.setSortingEnabled(True)
self
.
setStyleSheet
(
"Demo{background: rgb(249, 249, 249)} "
)
self
.
hBoxLayout
.
setContentsMargins
(
0
,
0
,
0
,
0
)
self
.
hBoxLayout
.
addWidget
(
self
.
tableView
)
self
.
resize
(
800
,
700
)
self
.
resize
(
625
,
700
)
if
__name__
==
"__main__"
:
...
...
qfluentwidgets/__init__.py
浏览文件 @
03ad7b99
...
...
@@ -12,7 +12,7 @@ Examples are available at https://github.com/zhiyiYo/PyQt-Fluent-Widgets/tree/ma
:license: GPLv3, see LICENSE for more details.
"""
__version__
=
"0.8.
0
"
__version__
=
"0.8.
2
"
from
.components
import
*
from
.common
import
*
...
...
qfluentwidgets/_rc/qss/dark/table_view.qss
浏览文件 @
03ad7b99
...
...
@@ -3,6 +3,7 @@ QTableView {
outline: none;
border: none;
font: 13px 'Segoe UI', 'Microsoft YaHei';
selection-background-color: transparent;
}
QTableView::item {
...
...
qfluentwidgets/_rc/qss/light/table_view.qss
浏览文件 @
03ad7b99
...
...
@@ -3,6 +3,7 @@ QTableView {
outline: none;
border: none;
font: 13px 'Segoe UI', 'Microsoft YaHei';
selection-background-color: transparent;
}
QTableView::item {
...
...
qfluentwidgets/_rc/resource.py
浏览文件 @
03ad7b99
此差异已折叠。
点击以展开。
qfluentwidgets/components/widgets/table_view.py
浏览文件 @
03ad7b99
# coding: utf-8
from
PyQt5
import
QtGui
from
typing
import
List
from
PyQt5.QtCore
import
Qt
,
QMargins
,
QModelIndex
from
PyQt5.QtGui
import
QPainter
,
QColor
from
PyQt5.QtWidgets
import
(
QStyledItemDelegate
,
QApplication
,
QStyleOptionViewItem
,
...
...
@@ -8,7 +9,6 @@ from PyQt5.QtWidgets import (QStyledItemDelegate, QApplication, QStyleOptionView
from
...common.smooth_scroll
import
SmoothScroll
from
...common.style_sheet
import
isDarkTheme
,
FluentStyleSheet
,
themeColor
from
.line_edit
import
LineEdit
from
.scroll_area
import
SmoothScrollBar
class
TableItemDelegate
(
QStyledItemDelegate
):
...
...
@@ -18,7 +18,7 @@ class TableItemDelegate(QStyledItemDelegate):
self
.
margin
=
2
self
.
hoverRow
=
-
1
self
.
pressedRow
=
-
1
self
.
currentRow
=
-
1
self
.
selectedRows
=
set
()
def
setHoverRow
(
self
,
row
:
int
):
self
.
hoverRow
=
row
...
...
@@ -26,10 +26,12 @@ class TableItemDelegate(QStyledItemDelegate):
def
setPressedRow
(
self
,
row
:
int
):
self
.
pressedRow
=
row
def
setCurrentRow
(
self
,
row
:
int
):
self
.
currentRow
=
row
if
row
==
self
.
pressedRow
:
self
.
pressedRow
=
-
1
def
setSelectedRows
(
self
,
indexes
:
List
[
QModelIndex
]):
self
.
selectedRows
.
clear
()
for
index
in
indexes
:
self
.
selectedRows
.
add
(
index
.
row
())
if
index
.
row
()
==
self
.
pressedRow
:
self
.
pressedRow
=
-
1
def
sizeHint
(
self
,
option
,
index
):
# increase original sizeHint to accommodate space needed for border
...
...
@@ -89,7 +91,7 @@ class TableItemDelegate(QStyledItemDelegate):
c
=
255
if
isDark
else
0
alpha
=
0
if
self
.
currentRow
!=
index
.
row
()
:
if
index
.
row
()
not
in
self
.
selectedRows
:
if
isPressed
:
alpha
=
9
if
isDark
else
6
elif
isHover
:
...
...
@@ -135,6 +137,7 @@ class TableBase:
self
.
setShowGrid
(
False
)
self
.
setMouseTracking
(
True
)
self
.
setItemDelegate
(
self
.
delegate
)
self
.
setSelectionBehavior
(
TableWidget
.
SelectRows
)
self
.
setVerticalScrollMode
(
QTableView
.
ScrollPerPixel
)
self
.
setHorizontalScrollMode
(
QTableView
.
ScrollPerPixel
)
...
...
@@ -155,8 +158,8 @@ class TableBase:
self
.
delegate
.
setPressedRow
(
row
)
self
.
viewport
().
update
()
def
set
CurrentRow
(
self
,
row
:
int
):
self
.
delegate
.
set
CurrentRow
(
row
)
def
set
SelectedRows
(
self
,
indexes
:
List
[
QModelIndex
]
):
self
.
delegate
.
set
SelectedRows
(
indexes
)
self
.
viewport
().
update
()
def
leaveEvent
(
self
,
e
):
...
...
@@ -178,11 +181,11 @@ class TableBase:
def
mouseReleaseEvent
(
self
,
e
):
row
=
self
.
indexAt
(
e
.
pos
()).
row
()
if
row
>=
0
and
e
.
button
()
!=
Qt
.
RightButton
:
self
.
set
CurrentRow
(
row
)
self
.
set
SelectedRows
(
self
.
selectedIndexes
()
)
else
:
self
.
setPressedRow
(
-
1
)
return
TableView
.
mouseReleaseEvent
(
self
,
e
)
return
Q
TableView
.
mouseReleaseEvent
(
self
,
e
)
class
TableWidget
(
QTableWidget
,
TableBase
):
...
...
@@ -192,6 +195,7 @@ class TableWidget(QTableWidget, TableBase):
super
().
__init__
(
parent
)
class
TableView
(
QTableView
,
TableBase
):
""" Table view """
...
...
setup.py
浏览文件 @
03ad7b99
...
...
@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools
.
setup
(
name
=
"PyQt-Fluent-Widgets"
,
version
=
"0.8.
0
"
,
version
=
"0.8.
2
"
,
keywords
=
"pyqt fluent widgets"
,
author
=
"zhiyiYo"
,
author_email
=
"shokokawaii@outlook.com"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录