pythonpatheasygui

easygui fileopenbox: open a path with a '.' (ex C:\Users\user\.atom)


I would like to open a file dialog with easygui but the path contains a folder with a .: C:\Users\user\.atom

myfile= easygui.fileopenbox(msg="Choose a file", default=r"C:\Users\user\.atom")

This opens the dialog box to C:\Users\user not C:\Users\user\.atom


Solution

  • I didn't / don't use easygui, just looked at the source code.

    easygui does some path processing on the default argument. That processing involves [Python]: os.path.split(path) which splits the path in 2 parts (what comes before and after the last path separator (bkslash or "\")).
    Since ".atom" comes after the last "\", it's not considered as part of the path (the fact that it contains a "." is just a coincidence and has nothing to do with it).

    To fix your problem, add a wildcard to your path, e.g.:

    myfile = easygui.fileopenbox(msg="Choose a file", default=r"C:\Users\user\.atom\*")