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.
The problem is when you have a single directory as a rootpath
and inside are only files, therefore no such movement is possible.
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.
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.
Let's say we have filechooser = FileChooserIconView()
:
filechooser._update_files()
works well and when is FileChooser
nested somewhere, it's easy to access it with id
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.)