Makie app from command line

How can I launch a Makie.jl based app from the command line?

I tried:

julia --project -e "include(\"./src/KiteViewer.jl\");main()"

which shortly shows the Makie windows but then terminates. How can I
achieve that it stays open until I close the Makie window?

Full source: https://github.com/ufechner7/KiteViewer

If you need to drop into REPL, use -i in the command line. It prevents immediate close when the execution ends.

julia --project -ie "include(\"./src/KiteViewer.jl\");main()"
4 Likes

Is it really necessary to invoke the REPL for this? For GTK.jl, for instance, there is a good description for using that framework without using the REPL. A standalone script shouldn’t need to drop into a different context.

I haven’t used Makie.jl very much, so I don’t know whether the recipe provided by GTK can be modified usefully.

1 Like

You can use similar mechanism but I don’t know if Makie exposes some function for exiting gui.

You can use:

using GLMakie
gl_screen = display(scatter(1:4));
wait(gl_screen)

Which will block as long as that window is open

8 Likes

Thanks for all the good replies!

I now use the following start script:

#!/bin/bash
cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
source ~/.bashrc

echo "Lauching KiteViewer..."
julia --optimize=1 --project -e "include(\"./src/KiteViewer.jl\");main(true)"

I need the second line to make sure the script also works when launched via a double click on a link to it that I have on the desktop.

Startup time is about 30s with Julia 1.6beta and optimization level one. Still some room for improvement, but good enough for now.

The main function looks like that:

function main(gl_wait=false)
    scene, layout = layoutscene(resolution = (840, 900), backgroundcolor = RGBf0(0.7, 0.8, 1))
    ...
    gl_screen = display(scene)

    if gl_wait
        wait(gl_screen)
    end
    return nothing
end

Just in case you missed it, you could compile an app for this with https://julialang.github.io/PackageCompiler.jl/dev/apps/#Creating-an-app-1, thus reducing time to first plot by a lot.

2 Likes

Yes, I could use package compiler, but for now my priority is to implement the full functionality of my program. And there is hope that also the latency without package compiler gets reduced much further: https://github.com/JuliaPlots/Makie.jl/issues/792

I see no other way forward other than cloning Julius, Simon, and Tim. Imagine the possibilities!

1 Like

The link is broken, please have a look here:

Hi,

I have tried to follow your idea of an Application, but I fail.
Do you have an idea what is missing:

Hi Stefan,
Posting on a 2 year old topic is not encouraged (also ominously called necroposting). Additionally, it’s not easy for people to help you if you only supply them with a link to a repo expecting them to figure out the problem on their own.
Instead, it’s best practice to start a new topic where you explain exactly what you tried and what went wrong. In fact, to get the best help possible, please follow these excellent suggestions as closely as you can.

Meanwhile, I was able to modify my project - mentioned above - in a way that the GLMakie-Application is now opperational as stand alone executable under MS Windows.
The main obsticle was the wrong starting point. The example in the PackageCompile-package is to complex for me and I do not understand which side-effects there are, if I delete or modify parts of it.
The important part of the code came from @sdanisch (see above):

gl_screen = display(scatter(1:4));
wait(gl_screen)
2 Likes