python - kivy:如何从 FileChooserListView 中的所有项目中删除突出显示
问题描述
我希望能够从 kivy FileChooserListView 中的所有项目中删除突出显示。我看到我可以通过将 FileChooserListView().selection 设置为空列表来删除实际选择[]
。但这不会删除以前选择的项目的突出显示。谢谢您的帮助。
解决方案
似乎没有任何方法可以直接做到这一点,但我认为这个丑陋的黑客会起作用:
class FakeEntry():
def __init__(self, **kwargs):
self.path = kwargs.pop('path', None)
class FakeEvent():
def __init__(self):
self.profile = []
self.button = None
self.is_double_tap = False
'''
Clear all selections in the specified FileChooser
'''
def clear_selection(file_chooser, *args):
layout = file_chooser.layout
if layout.VIEWNAME == 'list':
layout.ids.treeview.deselect_node()
fakeTouch = FakeEvent()
for path in file_chooser.selection[:]:
file_chooser.entry_touched(FakeEntry(path=path), fakeTouch)
推荐阅读
- .net - BouncyCastle 包使用 .NET Framework 版本恢复,但在 Linux 上运行良好
- java - Android将录像机视频保存到外部存储
- python - Pandas - 从具有混合值的一列创建两列
- sql - 为什么子查询在雪花中不起作用?
- android - google_maps_flutter 在从 CLI 运行时导致应用程序崩溃,但在构建和安装 apk 时不会
- ssh - SSH 配置注释掉匹配组管理员
- r - 执行计算时变异不添加正确的列名
- flutter - 错误:没有名为“selectableDayPredicate”的命名参数
- html - 我最后一节的高度有问题
- java - JOOQ + Gradle:如何为 JOOQ 生成器定义多个模式?