I’ve been trying to set up a Makie plot (using GLMakie) inside a GtkFrame (Gtk4.jl) and update it programmatically on demand. I can make it work with CairoMakie, but currently trying to use GLMakie instead to minimize latency and jitter. Any advice would be appreciated.
With the following example, I can set up a heatmap inside a GtkFrame/Window, but can’t seem to update the heatmap. I’ve also tried it without a observable, which also doesn’t work e.g.:
hm[3][] = new_data
using Gtk4, Gtk4Makie, GLMakie, Makie, Random
const W, H = 800, 500 # desired GL surface size inside the frame
# Window + layout
win = GtkWindow(; title = "Makie in GtkFrame (fixed size)", visible = false, resizable = false)
vbox = GtkBox(:v; spacing = 8)
win[] = vbox
frame = GtkFrame("Heatmap")
push!(vbox, frame)
# Makie widget (wraps a GtkGLArea)
glw = GtkMakieWidget()
# Lock the GTK widget to W×H and prevent expansion
set_gtk_property!(glw, :width_request, W)
set_gtk_property!(glw, :height_request, H)
set_gtk_property!(glw, :hexpand, false)
set_gtk_property!(glw, :vexpand, false)
frame[] = glw
# Build Makie figure with the NEW keyword:
fig = Figure(size = (W, H)) # <- use `size`, not `resolution`
ax = Axis(fig[1, 1], aspect = DataAspect())
Z = Observable(rand(Float32, 600, 400))
hm = heatmap!(ax, Z; interpolate = false, colorrange = (0f0, 1f0))
Colorbar(fig[1, 2], hm)
push!(glw, fig) # attach the figure to the GTK widget
show(win)
function push_new_data!()
@inbounds rand!(Z[])
notify(Z)
reveal(glw)
end