Correct usage of wx.DirDialog's GetPaths() with DD_multiple style?

Hi, I’ve been working on a program for few days, and in it I want to allow my user to select multiple directories. I was using wxpython to make my program, and found out wx.DirDialog’s GetPaths() method could possibly make this work.

But instead what I kept getting was ‘None’, and I am not either quite sure what an ‘array path’ is, nor what to fill in at the parameter of this method. What I want instead is a list of paths selected by the user.

This is the link to the specific method description, in the Class API page: wx.DirDialog — wxPython Phoenix 4.1.1 documentation

I am using Windows 10, Python 3.9.1, and wxPython 4.1.1.
Below is my code;

def getDirectories(self, event):

    global multipleDir
    global multipleExport

    dirs = []

    dlg = wx.DirDialog(None, "Choose input directory", "", wx.DD_MULTIPLE | wx.DD_DIR_MUST_EXIST)

    if dlg.ShowModal() != wx.ID_OK:
        print("You Cancelled The Dialog!")
        dlg.Destroy()
        return

    paths = dlg.GetPaths(dirs)

    print(paths)

    dlg.Destroy()

Thanks in advance.

DD_MULTIPLE is a fairly recent addition to wxWidgets. While much of the C++/Python translation is automated, GetPaths is one of those things that need a little special treatment, and it looks like DirDialog.GetPaths hasn’t had the benefit of @Robin’s TLC yet.

You should file an issue on the tracker.

1 Like

wx.lib.agw.multidirdialog may help tide you over for now.

1 Like

Thank you @AndersMunch, and yes I’ve checked wx.lib.agw.multidirdialog before, but I want to stick to using Window’s native filedialog system because of some reasons—mainly beacuse my ‘user’ wants it—so it seems I’ll have to wait, or make some changes on how this program works.

One of the main reasons I moved from TKinter to wxPython was because of the multi-directory selection, and this is just heartbreaking… But thank you so much for your reply!

Seems there’s one already :slight_smile: