KivyMD with plyer Filechooser - 如何获取目录的路径?

KivyMD with plyer Filechooser - How to get the path of a directory?

KivyMD 中,我经常使用 plyer Filechooser,在我看来,它非常适合获取桌面应用程序的文件路径。

问题我找不到获取目录路径的方法,目前我只能获取一份文件。你能帮我得到一个directory/folder的路径吗?

这是我的代码:

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

提前致谢

使用choose_dir代替open_file

尝试:https://plyer.readthedocs.io/en/latest/#plyer.facades.FileChooser.choose_dir