Kivy: drag n drop, get file path

In Kivy, I am trying to create an interface in which a user can drag a file into a widget (text input), and then my code will look for the path to the file system of this file (/ path / to / users. File). This seems like a simpler approach than using the FileChooser widget, but how would I do it?

Thanks!

+6
source share
1 answer

Use the on_dropfile event handler. Here is a working example:

 from kivy.app import App from kivy.core.window import Window class WindowFileDropExampleApp(App): def build(self): Window.bind(on_dropfile=self._on_file_drop) return def _on_file_drop(self, window, file_path): print(file_path) return if __name__ == '__main__': WindowFileDropExampleApp().run() 
+6
source

All Articles