Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
40415468
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看板
提交
40415468
编写于
4月 07, 2023
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加更多下拉框 api
上级
80551f82
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
76 addition
and
10 deletion
+76
-10
qfluentwidgets/__init__.py
qfluentwidgets/__init__.py
+1
-1
qfluentwidgets/components/widgets/combo_box.py
qfluentwidgets/components/widgets/combo_box.py
+74
-8
setup.py
setup.py
+1
-1
未找到文件。
qfluentwidgets/__init__.py
浏览文件 @
40415468
...
...
@@ -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.6.
5
"
__version__
=
"0.6.
6
"
from
.components
import
*
from
.common
import
*
...
...
qfluentwidgets/components/widgets/combo_box.py
浏览文件 @
40415468
...
...
@@ -31,10 +31,7 @@ class ComboItem:
"""
self
.
text
=
text
self
.
userData
=
userData
if
icon
:
self
.
_icon
=
QIcon
(
icon
)
if
isinstance
(
icon
,
str
)
else
icon
else
:
self
.
_icon
=
QIcon
()
self
.
icon
=
icon
@
property
def
icon
(
self
):
...
...
@@ -43,6 +40,13 @@ class ComboItem:
return
self
.
_icon
.
icon
()
@
icon
.
setter
def
icon
(
self
,
ico
:
Union
[
str
,
QIcon
,
FluentIconBase
]):
if
ico
:
self
.
_icon
=
QIcon
(
ico
)
if
isinstance
(
ico
,
str
)
else
ico
else
:
self
.
_icon
=
QIcon
()
class
ComboBoxBase
(
QObject
):
""" Combo box base """
...
...
@@ -75,7 +79,7 @@ class ComboBoxBase(QObject):
return
super
().
eventFilter
(
obj
,
e
)
def
addItem
(
self
,
text
,
icon
:
Union
[
str
,
QIcon
,
FluentIconBase
]
=
None
,
userData
=
None
):
def
addItem
(
self
,
text
:
str
,
icon
:
Union
[
str
,
QIcon
,
FluentIconBase
]
=
None
,
userData
=
None
):
""" add item
Parameters
...
...
@@ -127,7 +131,7 @@ class ComboBoxBase(QObject):
def
currentIndex
(
self
):
return
self
.
_currentIndex
def
setCurrentIndex
(
self
,
index
):
def
setCurrentIndex
(
self
,
index
:
int
):
""" set current index
Parameters
...
...
@@ -151,6 +155,12 @@ class ComboBoxBase(QObject):
return
self
.
items
[
self
.
currentIndex
()].
text
def
currentData
(
self
):
if
not
0
<=
self
.
currentIndex
()
<
len
(
self
.
items
):
return
None
return
self
.
items
[
self
.
currentIndex
()].
userData
def
setCurrentText
(
self
,
text
):
""" set the current text displayed in combo box,
text should be in the item list
...
...
@@ -186,17 +196,36 @@ class ComboBoxBase(QObject):
self
.
setText
(
text
)
def
itemData
(
self
,
index
:
int
):
""" Returns the data
for the given role in the given index in the combobo
x """
""" Returns the data
in the given inde
x """
if
not
0
<=
index
<
len
(
self
.
items
):
return
None
return
self
.
items
[
index
].
userData
def
itemText
(
self
,
index
:
int
):
""" Returns the text in the given index """
if
not
0
<=
index
<
len
(
self
.
items
):
return
''
return
self
.
items
[
index
].
text
def
itemIcon
(
self
,
index
:
int
):
""" Returns the icon in the given index """
if
not
0
<=
index
<
len
(
self
.
items
):
return
QIcon
()
return
self
.
items
[
index
].
icon
def
setItemData
(
self
,
index
:
int
,
value
):
""" Sets the data role for the item on the given index
in the combobox to the specified value
"""
""" Sets the data role for the item on the given index """
if
0
<=
index
<
len
(
self
.
items
):
self
.
items
[
index
].
userData
=
value
def
setItemIcon
(
self
,
index
:
int
,
icon
:
Union
[
str
,
QIcon
,
FluentIconBase
]):
""" Sets the data role for the item on the given index """
if
0
<=
index
<
len
(
self
.
items
):
self
.
items
[
index
].
icon
=
icon
def
findData
(
self
,
data
):
""" Returns the index of the item containing the given data, otherwise returns -1 """
for
i
,
item
in
enumerate
(
self
.
items
):
...
...
@@ -212,6 +241,43 @@ class ComboBoxBase(QObject):
return
self
.
items
.
index
(
self
.
itemMap
[
text
])
def
clear
(
self
):
""" Clears the combobox, removing all items. """
self
.
items
.
clear
()
self
.
itemMap
.
clear
()
self
.
_currentIndex
=
-
1
def
count
(
self
):
""" Returns the number of items in the combobox """
return
len
(
self
.
items
)
def
insertItem
(
self
,
index
:
int
,
text
:
str
,
icon
:
Union
[
str
,
QIcon
,
FluentIconBase
]
=
None
,
userData
=
None
):
""" Inserts item into the combobox at the given index. """
if
not
text
or
text
in
self
.
itemMap
:
return
item
=
ComboItem
(
text
,
icon
,
userData
)
self
.
items
.
insert
(
index
,
item
)
self
.
itemMap
[
text
]
=
item
if
index
<=
self
.
currentIndex
():
self
.
_onItemClicked
(
self
.
currentIndex
()
+
1
)
def
insertItems
(
self
,
index
:
int
,
texts
:
Iterable
[
str
]):
""" Inserts items into the combobox, starting at the index specified. """
pos
=
index
for
text
in
texts
:
if
not
text
or
text
in
self
.
itemMap
:
continue
item
=
ComboItem
(
text
)
self
.
items
.
insert
(
pos
,
item
)
self
.
itemMap
[
text
]
=
item
pos
+=
1
if
index
<=
self
.
currentIndex
():
self
.
_onItemClicked
(
self
.
currentIndex
()
+
pos
-
index
)
def
_closeComboMenu
(
self
):
if
not
self
.
dropMenu
:
return
...
...
setup.py
浏览文件 @
40415468
...
...
@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools
.
setup
(
name
=
"PyQt-Fluent-Widgets"
,
version
=
"0.6.
5
"
,
version
=
"0.6.
6
"
,
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录