gpt4 book ai didi

python - Kivy 文件选择器问题

转载 作者:太空宇宙 更新时间:2023-11-04 03:52:45 25 4
gpt4 key购买 nike

我正在使用基于 Kivy 示例演示的文件选择器:

.kv 文件:

        FileChooserListView:
id: list_view_tab
path: '.'
on_selection: nada = app.loader(list_view_tab.selection)

FileChooserIconView:
id: icon_view_tab
show_hidden: True
on_selection: nada = app.loader(icon_view_tab.selection)

...

TextInput:
size_hint: (None, 1)
id: filtro
text: '*.py'
multiline: False
on_text: list_view_tab.filters = icon_view_tab.filters = text.split(',')

.py 代码中没有对这些小部件的直接引用,它显示文件系统在两种方式都正常。

我有这些问题:

  • 过滤器不起作用。我错过了什么?

  • FileChooserListView 中有列名 NameSize。我如何将这些更改为其他语言?

  • 如何通过单击选择文件?

最佳答案

The filter doesn't work. What have I missed?

您为两个 FileChooserListView 设置了 filter 属性,但这似乎不存在。您应该改为设置 filters 属性,该属性必须是字符串列表。这记录在案 here在 kivy 文档中。

In the FileChooserListView there are the column names Name and Size. How can I change these for other languages?

我不认为这在 api 中公开,尽管它可能应该公开。现在,您可能必须更改您的 kivy 源。相关行在kivy/data/style.kv的FileChooserListView规则中,可以找到here在 kivy 的 github 上。

How can I select files by single click?

我不确定最佳方法,但我可能会查看 FileChooserListView 的 selection 属性。作为一个 kivy 属性,这将在选择更改时调用方法 on_selection,因此您可以将所需的行为放在那里。

选择更改的确切方式和时间可能有些繁琐,但这似乎是正确的选择。

关于python - Kivy 文件选择器问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20426350/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com