Search code examples
python-3.xfilekivytext-files

How to upload a text file to a window in Kivi, Python


Hellow, I need my application to receive a text file by 'dragging and dropping'. It is fundamentally important that the place where I will drag the file is in the application window.


Solution

  • Many time has passed

    To upload file you need:

    Make Window.bind(on_drop_file=self.onFileDrop)

    def build(self):
       Window.bind(on_drop_file=self.onFileDrop)
    

    where 'on_drop_file' is name of Event, what will be with your window onFileDrop is function, witch you use

    def onFileDrop(self, window, file_path, *agrs):
       #type(file_path) = bytes
    

    have a good day :)