# How to place a menu in GLMakie?

**URL:** <https://discourse.julialang.org/t/how-to-place-a-menu-in-glmakie/112025>\
**Category:** Visualization\
**Tags:** question, package, gui, glmakie\
**Created:** [March 23, 2024, 9:13pm UTC](https://discourse.julialang.org/t/how-to-place-a-menu-in-glmakie/112025 "2024-03-23T21:13:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [March 23, 2024, 9:13pm UTC](https://discourse.julialang.org/t/how-to-place-a-menu-in-glmakie/112025/1 "2024-03-23T21:13:14Z")

</div>

I have the following code:

```julia
using GLMakie

const running = Observable(false)
fig = Figure(size=(400, 400), backgroundcolor=RGBf(0.7, 0.8, 1))
sub_fig = fig[1,1]
fig[2, 1] = buttongrid = GridLayout(tellwidth=true)
btn_PLAY_PAUSE = Button(sub_fig, label = @lift($running ? "PAUSE" : " RUN "))
btn_STOP = Button(sub_fig, label="STOP")
buttongrid[1, 1:2] = [btn_PLAY_PAUSE, btn_STOP]

menu1 = Menu(fig[1,1], options = ["plot", "save as jld2", "save as pdf"], default = "plot")
menu1.width[]=100
menu1.halign[]=:left
menu1.valign[]=:top
fig

```

How can I place the menu at the top left side of the window with a small, well defined distance to the window border?

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [March 23, 2024, 9:25pm UTC](https://discourse.julialang.org/t/how-to-place-a-menu-in-glmakie/112025/2 "2024-03-23T21:25:22Z")

</div>

Does it work the same as legends? [Legend · Makie](https://docs.makie.org/stable/reference/blocks/legend/#legend_inside_an_axis)

---

<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:** [March 23, 2024, 9:34pm UTC](https://discourse.julialang.org/t/how-to-place-a-menu-in-glmakie/112025/3 "2024-03-23T21:34:16Z")

</div>

Give the menu alignmode=Outside(padding)

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [March 23, 2024, 9:38pm UTC](https://discourse.julialang.org/t/how-to-place-a-menu-in-glmakie/112025/4 "2024-03-23T21:38:54Z")

</div>

> [@jules](#):
>
> Outside(padding)

 ![Screenshot from 2024-03-23 22-37-04](https://global.discourse-cdn.com/julialang/original/3X/7/f/7f5694801e69c82b38328581f361d539a1ed406f.png)

```julia
using GLMakie

const running = Observable(false)
fig = Figure(size=(400, 400), backgroundcolor=RGBf(0.7, 0.8, 1))
sub_fig = fig[1,1]
fig[2, 1] = buttongrid = GridLayout(tellwidth=true)
btn_PLAY_PAUSE = Button(sub_fig, label = @lift($running ? "PAUSE" : " RUN "))
btn_STOP = Button(sub_fig, label="STOP")
buttongrid[1, 1:2] = [btn_PLAY_PAUSE, btn_STOP]

menu1 = Menu(fig, options = ["plot", "save as jld2", "save as pdf"], default = "plot")
menu1.width[]=100
menu1.halign[]=:left
menu1.valign[]=:top
menu1.alignmode[]=Outside(10)
fig

```

Padding works fine now, but the menu is not yet at the top…

---

<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:** [March 23, 2024, 9:41pm UTC](https://discourse.julialang.org/t/how-to-place-a-menu-in-glmakie/112025/5 "2024-03-23T21:41:55Z")

</div>

Because you changed your code, now it’s just `Menu(fig,` which will put the menu in the default 100x100 square as bbox. You can either choose a layout cell or do `bbox = fig.scene.viewport`

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [March 23, 2024, 9:50pm UTC](https://discourse.julialang.org/t/how-to-place-a-menu-in-glmakie/112025/6 "2024-03-23T21:50:12Z")

</div>

> [@jules](#):
>
> `bbox = fig.scene.viewport`

This works:

```julia
using GLMakie

const running = Observable(false)
fig = Figure(size=(400, 400), backgroundcolor=RGBf(0.7, 0.8, 1))
sub_fig = fig[1,1]
fig[2, 1] = buttongrid = GridLayout(tellwidth=true)
btn_PLAY_PAUSE = Button(sub_fig, label = @lift($running ? "PAUSE" : " RUN "))
btn_STOP = Button(sub_fig, label="STOP")
buttongrid[1, 1:2] = [btn_PLAY_PAUSE, btn_STOP]

menu1 = Menu(fig, bbox = fig.scene.viewport, options = ["plot", "save as jld2", "save as pdf"], default = "plot")
menu1.width[]=100
menu1.halign[]=:left
menu1.valign[]=:top
menu1.alignmode[]=Outside(10)
fig

```

Thank you!

But, to be honest, the documentation does not really mention this.

---

<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:** [March 24, 2024, 6:57am UTC](https://discourse.julialang.org/t/how-to-place-a-menu-in-glmakie/112025/7 "2024-03-24T06:57:22Z")

</div>

It’s hard to mention every possible combination of things you can do in Makie 🙂 the bbox thing is definitely mentioned in a couple places, and the viewport rectangle too, this is just a combination of the two, you could use any other rectangle observable

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [March 24, 2024, 11:56am UTC](https://discourse.julialang.org/t/how-to-place-a-menu-in-glmakie/112025/8 "2024-03-24T11:56:41Z")

</div>

I created an issue: [Help insufficient · Issue #3730 · MakieOrg/Makie.jl · GitHub](https://github.com/MakieOrg/Makie.jl/issues/3730)
