I am creating a GUI in Makie, and I would like to be able to change the layout with a menu widget. So far, I can add widgets (GridLaouts) at runtime, but I didn’t find how to hide or replace them. See the mwe below. It should switch between layouts, but it puts one over another instead.
items =["buttons", "slider"]
fig = Figure()
fig[1,1] = menu = Menu(fig, options=items)
on(menu.selection) do s
if s == "buttons"
fig[2,1] = gl1 = GridLayout()
gl1[1,1] = Button(fig, label ="button 1")
gl1[1,2] = Button(fig, label ="button 2")
fig[2,1] = gl2 = GridLayout()
gl2[1,1] = Slider(fig, range= 0:1)
The GridLayout is not visible so you can’t hide it, only the objects placed using it. But there’s currently no great way to hide Block objects. What I’ve done once a long time ago was to place an independent GridLayout offscreen and put things in that to “hide” them. In your case you could move gl1 or gl2 there whenever you need the other one. To place a grid outside, use the bbox argument with a negative boundingbox like bbox = BBox(-200, -100, 0, 100)