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

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: https://docs.wxpython.org/wx.DirDialog.html#wx.DirDialog.GetPaths

It just says:

GetPaths(self, paths)
    Fills the array paths with the full paths of the chosen directories.

    Parameters
        paths (list of strings)–

    New in version 4.1/wxWidgets-3.1.4.

    Note: This function should only be used with the dialogs which have DD_MULTIPLE style, use GetPath for the others.

Sorry if this is a bad question, but I just seem to lack searching skills to dig deeper than the Class API page about what an 'array path' is. DD_MULTIPLE style on wx.DirDialog seems quite new, and there isn't much to read from on the web.

And also, I am trying to stick to using Window's filedialog system, so any answers using wx.lib.agw.multidirdialog is much appreciated, but I'll pass on that.

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

Thank you in advance.



Solution 1:[1]

Aren't you supposed to use dirs, not paths?

If this doesn't work neither then, considering that the equivalent C++ code in wxWidgets dialogs sample (see the code around this line) works fine, it would mean that there is something wrong with wrapping this function in Python and you should try reporting this as a bug if it hasn't been done yet.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 VZ.