File picker for Makie

hello, i’m new to Makie and i’m trying to build a GUI to plot data from a CSV file.
to load the file i want the user to choose a CSV and then pars the data to the plot.
i was looking for something like the “filepicker” from the “interact.jl” pkg. but didn’t find one.
can i implement the filepicker from interact with in the Makie Scene?
if not then how can i create a gui to load a CSV file using Makie?
thanks in ahead
miki

1 Like

I’m curious, did you end up finding a suitable file picker?

hi,
It been a while, but recently I got back to this issue and my workaround for this was as follow:
for windows I created a .bat file with the following code:

@echo off
set dialog="about:<input type=file id=FILE><script>FILE.click();new ActiveXObject
set dialog=%dialog%('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(FILE.value);
set dialog=%dialog%close();resizeTo(0,0);</script>"

for /f "tokens=* delims=" %%p in ('mshta.exe %dialog%') do set "file=%%p"
echo %file%

finally I created the following julia functions:

abstract type SysTypes end
struct Windows <: SysTypes end
struct Linux <: SysTypes end

function filebrowser()
    if Sys.iswindows()
        res = filebrowser(Windows)
    end

    if Sys.islinux()
        res = filebrowser(Linux)
    end
    return res
end

function filebrowser(::Type{Windows})
    filetorun = joinpath(@__DIR__,"../aux_files/fileBrowserWindows.bat")
    filename = String(read(`$filetorun`))
    return splitdir(strip(filename,['\r','\n']))
end

function filebrowser(::Type{Linux})
    comm = `zenity --file-selection`
    filename = String(read(comm))
    return splitdir(strip(filename,['\n']))
end

hope it is still relevant and help you.

1 Like

That’s great!

I am using now this code:

using GLMakie, NativeFileDialog

fig = Figure(size=(200, 200), backgroundcolor=RGBf(0.7, 0.8, 1))
btn_RUN  = Button(fig, label = " Open file... ")
on(btn_RUN.clicks) do c;
    @async begin 
        filename = fetch(Threads.@spawn pick_file(""))
        println(filename)
    end
end
fig

which works fine…

4 Likes