1

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.

Peter Badida
  • 11,310
  • 10
  • 44
  • 90

1 Answers1

5

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.)

Peter Badida
  • 11,310
  • 10
  • 44
  • 90
  • Just a note, that given _update_files is an internal function, it would be good for somebody to eventually open a feature request with kivy that the function be exposed as part of the api, so it doesn't change in some upgrade. – fuzzyTew Nov 16 '20 at 14:20