Simplest way to launch a file browser

Is there some extremely lighweight package that allows choosing a file that will be an input to a function in some “point and click” way?

(It is really hard to make Windows users happy with anything that requires typing, and for some reason Windows makes all efforts to hide the true paths of the files).

Maybe: how dependency-independent can be a function that launches a browser and shows a page with a simple form that runs a function in background?

I want the users just to use something like:

julia> run_function("C:\\users\\myname\\Downloads\\inputfile.inp")

and requiring typing the path is pain on Windows, because you have to provide a video showing people how to get the path, and then ask them to add the double back slashes.

For the file input part, does the NativeFileDialog.jl package help?

6 Likes

A side-note on Windows filepaths: you can avoid needing to add backslashes by preprending raw to the string.

julia> raw"C:\Users\MyName\Downloads\inputfile.inp"
"C:\\Users\\MyName\\Downloads\\inputfile.inp"
3 Likes

@lmiq any chance this is related to Pluto.jl? Are you launching the browser to start a Pluto session?

There are ways to create a Windows batch or Linux shell script to automate the task with mouse clicks.

No, not really. What @rafael.guerra suggested is what I was searching for, just opening a dialog, because I found that the easiest way to provide cross-platform executables for a Fortran package is to use BinaryBuilder.jl and make a thin wrapper to it. With the file browser being launched I think Windows users will finally run it easily. (GitHub - m3g/Packmol.jl: The future of Packmol).

(I’m not sure if the NativeFileDialog is lightweight, but it installs and runs quickly at least).

edit: it seems to be a pretty large dependency, but still much easier (on Windows) than compiling the package. For now I’m happy with it.