問題描述
目前我經常使用 FileChooser
并且我沒有在 文檔.小部件很棒,但是如果有人想刷新顯示的文件,則需要從當前目錄移動以刷新文件.
Currently I'm working with FileChooser
a lot and I didn't find any mention of refreshing the widget in the docs. The widget is awesome, but if someone wants to refresh shown files, a movement from current directory is necessary to refresh files.
問題是當你有一個 single 目錄作為 rootpath
并且里面只有文件時,因此不可能進行這樣的移動.
The problem is when you have a single directory as a rootpath
and inside are only files, therefore no such movement is possible.
我的問題是如何刷新小部件,如果我想避免任何浪費的刪除/添加 FileChooser
并盡可能縮短 FileChooser
非常嵌套在 kv
文件中.
My question was how to refresh the widget if I want to avoid any wasteful removing/adding of FileChooser
and do it as short as possible for a FileChooser
that is very nested in a kv
file.
推薦答案
我搜索了 filechooser.py
找到了 code 在目錄之間的每次移動時觸發.考慮到 FileChooserIconView
和 FileChooserListView
繼承自 FileChooserController
的事實,對函數的訪問很簡單,不需要額外的導入.
After I searched filechooser.py
I found the code which is triggered on each movement between directories. Giving the fact the FileChooserIconView
and FileChooserListView
inherit from FileChooserController
, the access to the function is simple and no additional imports are required.
假設我們有 filechooser = FileChooserIconView()
:
filechooser._update_files()
運行良好,當 FileChooser
嵌套在某處時,使用 id
filechooser._update_files()
works well and when is FileChooser
nested somewhere, it's easy to access it with id
如需更多調整,Clock.schedule_interval(filechooser._update_files, t)
可能會對您在合理時間內更新目錄內容有所幫助.
For more tweaks Clock.schedule_interval(filechooser._update_files, t)
may be helpful where you can update your directory content within a reasonable time.
(我在這里添加它,因為我沒有發現它,但是它可能對某人有用.)
(I add it here, because I found no mention of it, however it may be useful to someone.)
這篇關于刷新/重新加載 FileChooser的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!