QML, animations, and asynchronous variable updating


I’m trying to build a simple GUI for a metropolis Monte Carlo simulation of a spin ising model. What I want to do, basically is having a while loop in the background running at all times (ideally which can be paused), which is updating the underlying state of my simulation. I’m trying to do this with QML, but whether I loop in QML or in Julia, the interface only checks the JuliaInterface once the loop is finished. At the same time I want to have some slider that parametrises the temperature of my simulation, which I can change asynchronously, mid-simulation

Right now I’m just pushing raw pixel data to display, and displaying it in qml using display(julia_display,raw_data).

I’ve tried using observables as well, but the problem remains that the display is only finished after the complete function is done running. Does anyone have any experience either with QML.jl or some other packages with which I could achieve something like this?

I found that defining a function with a while loop inside using the Threads.@spawn does the trick. I can now call this function from QML and the loop will be initiated, running in the background and continuously updating the screen. If I do too many updates, however, I get flickering of the screen.