Wrapper of the library mlabbe/nativefiledialog for opening native OS dialogues for selecting files (or Gtk for Linux/FreeBSD). Inspired by this discourse post.
To install NativeFileDialog.jl, in the Julia REPL
julia> using Pkg
julia> Pkg.add("NativeFileDialog")NativeFileDialog.jl export four functions
pick_file(path=""; filterlist="")
pick_multi_file(path=""; filterlist="")
pick_folder(path="")
save_file(path=""; filterlist="")The documentation of every one of these can be consulted in help mode in the
REPL (press ? to change to help mode, backspace to exit), although their
names are really descriptive.
The path positional argument sets the directory in which the dialog will be
open, by default path is set to "" and the default open point is operating
system dependent.
The path argument accepts AbstractPaths from
FilePathsBase.jl. When
a <:AbstractPath has been passed it returns nothing on cancellations for
every one of the functions.
The filterlist keyword argument allows you to define multiple extension
filters for the dialogues. The syntax for doing this is "ext1,ext2;ext3"
where ext1 and ext2 are extensions of the first filter list and ext3 is
an extension for the second one.
Notice that multiple extensions for one list are separated by a comma (,),
while the different lists are separated by a semicolon (;).
By default filterlist is set to "" which means all kind of files are
accepted.
julia> using NativeFileDialog
julia> using FilePathsBase
julia> pick_file()
"/home/suave/primes.c"
julia> pick_file(home()) # from FilePathsBase
p"/home/suave/donut.c"
julia> pick_file()
"" # cancelled selection
julia> pick_multi_file()
2-element Vector{String}:
"/home/suave/aek.cpp"
"/home/suave/aek.ppm"
julia> pick_folder()
"/home/suave"