# Removing row from GridLayout

**URL:** <https://discourse.julialang.org/t/removing-row-from-gridlayout/93196>\
**Category:** General Usage\
**Tags:** makie\
**Created:** [January 19, 2023, 8:10am UTC](https://discourse.julialang.org/t/removing-row-from-gridlayout/93196 "2023-01-19T08:10:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Lewis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/daniel_lewis/32/31250_2.png) [@Daniel\_Lewis](https://discourse.julialang.org/u/Daniel_Lewis)\
**Post date:** [January 19, 2023, 8:10am UTC](https://discourse.julialang.org/t/removing-row-from-gridlayout/93196/1 "2023-01-19T08:10:25Z")

</div>

hi,  
I’m trying to create an interactive plot using GLMakie, one of the thing I’m doing is adding menus from which the user can choose the data to plot.  
Here is a simplified code which create the menus GridLayout:

```julia
using GLMakie

fig = Figure()
menugrid = GridLayout(tellwidth = false, tellhight= false)
x_menu_l = Label(fig.scene, "X : ")
x_table_m = Menu(fig.scene)
x_var_m = Menu(fig.scene)
menugrid[1,1:3] = [x_menu_l, x_table_m, x_var_m]

y_menu_l = [Label(fig.scene, "Y : ") for _ in 1:4]
y_table_m = [Menu(fig.scene) for _ in 1:4]
y_var_m = [Menu(fig.scene) for _ in 1:4]
y_rm_m = [Button(fig.scene, label = "Rem") for _ in 1:4]
 
# adding 4 more rows to the grid
for (a,b,c,d) in zip(y_menu_l, y_table_m, y_var_m, y_rm_m)
    menugrid[end+1,1:4] = [a, b, c, d]
end

```

My question is, how can I remove the i’th row from the menugrid and update the GUI?  
thanks in ahead

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [January 19, 2023, 8:31am UTC](https://discourse.julialang.org/t/removing-row-from-gridlayout/93196/2 "2023-01-19T08:31:51Z")

</div>

In principle like this

```julia
for c in contents(menugrid[end, :])
    delete!(c)
end
trim!(menugrid)

```

But currently the removed objects will still stick around in the figure, just detached from the layout. We need to fix that.

---

<div class="post-metadata">

**Author:** ![Daniel\_Lewis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/daniel_lewis/32/31250_2.png) [@Daniel\_Lewis](https://discourse.julialang.org/u/Daniel_Lewis)\
**Post date:** [January 19, 2023, 8:41am UTC](https://discourse.julialang.org/t/removing-row-from-gridlayout/93196/3 "2023-01-19T08:41:03Z")

</div>

thank you for the quick answer.  
So as I understand it at this point I can’t fully remove it.  
I’ll try to think of a walk around solution.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [January 19, 2023, 8:42am UTC](https://discourse.julialang.org/t/removing-row-from-gridlayout/93196/4 "2023-01-19T08:42:23Z")

</div>

Interestingly, if I redisplay the figure after removal, the objects are gone. So they are removed at some layer, just not from the live figure.

---

<div class="post-metadata">

**Author:** ![Daniel\_Lewis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/daniel_lewis/32/31250_2.png) [@Daniel\_Lewis](https://discourse.julialang.org/u/Daniel_Lewis)\
**Post date:** [January 19, 2023, 8:49am UTC](https://discourse.julialang.org/t/removing-row-from-gridlayout/93196/5 "2023-01-19T08:49:22Z")

</div>

That’s true, is there any update \ refresh command to the figure with out closing and redisplaying it?

---

<div class="post-metadata">

**Author:** ![ffreyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffreyer/32/21569_2.png) [@ffreyer](https://discourse.julialang.org/u/ffreyer)\
**Post date:** [January 19, 2023, 9:49am UTC](https://discourse.julialang.org/t/removing-row-from-gridlayout/93196/6 "2023-01-19T09:49:35Z")

</div>

This should work for clearing plots:

```julia
for c in contents(menugrid[end, :])
    # clean up plots and some observables
    empty!(c.blockscene)

    delete!(c)
end
trim!(menugrid)

```

I’m not sure how complete the observable cleanup is with this. I wouldn’t be surprised if this leaves behind some ghost interactions, like an invisible button you can still press. If that is the case it would be good to open an issue for this.
