Persona
Persona

Reputation: 63

Can someone explain me why plyer filechooser doesn't work on my android device?

I'm new in plyer and kivy. I would open a filechooser window when a button is clicked. The problems is: on click of button the window appear but first send None as selection. Here my code:

`def select_path(self, path): if path is not None:

        print("Ecco",path)
        pass
    else:
        print("Ok",path)


def file_manager_open(self):

    path = filechooser.open_file(title='ciao')

    path = str(path)
    print("Percorso:",path)
    self.select_path(path)`

And here my button code:

MDIconButton: icon:"table-arrow-right" pos_hint:{"center_x":0.1,"center_y":0.9} on_release:app.file_manager_open()

Upvotes: 1

Views: 617

Answers (2)

Fabian Joseph
Fabian Joseph

Reputation: 48

The problem is with your syntax, You have to set a callback function for the filechooser this way

def parseChoice(file_paths:list):
    print('File path ', file_paths[0])
filechooser.open_file(on_selection=parseChoice)

Upvotes: 0

krokkered
krokkered

Reputation: 23

path is a list, so probably path[0] will do the trick ciao!

Upvotes: 0

Related Questions