# Gtk. How do I create a submenu?

**URL:** <https://discourse.julialang.org/t/gtk-how-do-i-create-a-submenu/75418>\
**Category:** General Usage\
**Tags:** question, guis, gtk\
**Created:** [January 29, 2022, 3:22pm UTC](https://discourse.julialang.org/t/gtk-how-do-i-create-a-submenu/75418 "2022-01-29T15:22:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![johntrinder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johntrinder/32/31783_2.png) [@johntrinder](https://discourse.julialang.org/u/johntrinder)\
**Post date:** [January 29, 2022, 3:22pm UTC](https://discourse.julialang.org/t/gtk-how-do-i-create-a-submenu/75418/1 "2022-01-29T15:22:09Z")

</div>

I’m still a beginner at Gtk GUI interface package.  
I’ve googled a lot, but I can’t find any code snippets for how to create a submenu in Julia.  
Could someone please advise.

---

<div class="post-metadata">

**Author:** ![johntrinder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johntrinder/32/31783_2.png) [@johntrinder](https://discourse.julialang.org/u/johntrinder)\
**Post date:** [January 29, 2022, 3:46pm UTC](https://discourse.julialang.org/t/gtk-how-do-i-create-a-submenu/75418/2 "2022-01-29T15:46:09Z")

</div>

Have tried obj=Gtk.GAccessor.submenu(aMenuItem) and the error is UndefRefError: access to undefined reference

---

<div class="post-metadata">

**Author:** ![johntrinder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johntrinder/32/31783_2.png) [@johntrinder](https://discourse.julialang.org/u/johntrinder)\
**Post date:** [January 29, 2022, 7:31pm UTC](https://discourse.julialang.org/t/gtk-how-do-i-create-a-submenu/75418/3 "2022-01-29T19:31:48Z")

</div>

Finally sussed it:

using Gtk, Gtk.ShortNames

file = MenuItem(“\_File”)  
filemenu = Menu(file)

new\_ = MenuItem(“New”)  
push!(filemenu, new\_)  
open\_ = MenuItem(“Open”)  
push!(filemenu, open\_)  
push!(filemenu, SeparatorMenuItem())  
quit = MenuItem(“Quit”)  
push!(filemenu, quit)

a\_submenu = Menu()  
diddly = MenuItem(“diddly”)  
push!(a\_submenu, diddly)  
diddlydoo = MenuItem(“diddlydoo”)  
push!(a\_submenu, diddlydoo)

Gtk.GAccessor.submenu(open\_, a\_submenu)

mb = MenuBar()  
push!(mb, file) # notice this is the “File” item, not filemenu

win = Window(mb, “Menus”, 200, 40)  
showall(mb)
