How to animate a slider in GLMakie?

Hi,
I want to animate a slider when I press a button.
The slider should move from a start value to an end value, but it jumps right to the end, though I use sleep, and checked that the for loop works correct.

using GLMakie

fig = Figure(resolution=(1200, 700))
ax = Axis(fig[1, 1])

sliderT = Slider(fig[2, 1], range = 1:25, startvalue = 1)

fig[3, 1] = buttongrid = GridLayout(tellwidth = false)
button = buttongrid[1, 1] = Button(fig, label = "▶ / ||")

on(button.clicks) do _

    # Somewhere here's the problem I guess
    for i in 1:20
        set_close_to!(sliderT, i)
        sleep(0.01)
        println(i)
    end
    
end

display(fig)

Do you have any ideas?
Thanks

Running asynchronously allows the figure to update.
@async for i in 1:20

1 Like

It works perfectly, thank you very much!