in the MWE below, “start” is never displayed. is there a way to make it so?
using GLMakie
f = Figure()
b = Button(f[1,1], label="foo")
l = Label(f[1,2], "")
on(b.clicks) do _
l.text[] = "start"
sleep(1) # long running calculation
l.text[] = "finish"
end
The problem is sleep
is running in the same task as the GUI updates, so until this function returns no graphical updates can happen. The solution is to launch the long-running function in its own task:
using GLMakie
f = Figure()
b = Button(f[1,1], label="foo")
l = Label(f[1,2], "")
on(b.clicks) do _
l.text[] = "start"
@async begin
sleep(1) # long running calculation
l.text[] = "finish"
end
end