In KivyMD
I use often the plyer Filechooser
that looks to me really good for getting the path of a file, for a desktop application.
PROBLEM: I cannot find a way to get the path of a directory, I can get at the moment only the path of a file. Can you help me to get the path of a directory/folder?
Here my code:
from plyer import filechooser
from kivymd.app import MDApp
from kivy.lang import Builder
from plyer import filechooser
KV = """
BoxLayout:
id: box
orientation: "vertical"
# size_hint: None, None
# size: self.minimum_size
# pos_hint: {"center_x": .5}
spacing: dp(10)
padding: dp(30)
MDRoundFlatButton:
id: openPathID
text: "Get url"
pos_hint: {'center_x': .5}
on_release: app.file_manager_open()
MDLabel:
id: my_custom_label
text: "URL"
halign: 'center'
"""
class DemoApp(MDApp):
def build(self):
return Builder.load_string(KV)
def file_manager_open(self):
raw_path = filechooser.open_file(title="Carica il file tempi in formato .xlsx",
filters=[("Comma-separated Values", "*.xlsx")])
self.root.ids.my_custom_label.text = raw_path[0]
DemoApp().run()
Thanks in advance
use choose_dir
instead of open_file
try: https://plyer.readthedocs.io/en/latest/#plyer.facades.FileChooser.choose_dir