GtkDropDown menu list update

Hello Everyone,

I am creating my first GUI and got stuck. I defined the GUI in xml format and then used GTK4 and the GtkBuilder in the Julia code. The window appears with no problem. I just can’t figure out how to change the list of options in the dropdown menu after the widget is created. The example in the tutorial does not seem to work. Can’t link it properly due to julia site error:
(https://docs.juliahub.com/Gtk4/rFcBQ/0.7.3/manual/combobox/)
Here is the MWE of my program:

using Gtk4

b = GtkBuilder("ui.xml")
win = b["window"]
show(win)

reactor=("1")

reactor_ddm = b["reactor_dd"]
push!(Gtk4.model(reactor_ddm), reactor)

if !isinteractive()
    @async Gtk4.GLib.glib_main()
    Gtk4.GLib.waitforsignal(win,:close_request)
end

This is the error I get:

ERROR: LoadError: MethodError: no method matching push!(::Nothing, ::String)
The function push! exists, but no method is defined for this combination of argument types.

Closest candidates are:
push!(::Any, ::Any, ::Any)
@ Base abstractarray.jl:3529
push!(::Any, ::Any, ::Any, ::Any…)
@ Base abstractarray.jl:3530
push!(::Base.Nowhere, ::Any)
@ Base array.jl:1821

Thanks in advance for the help!

It looks like the call to Gtk4.model is returning nothing, which happens when there is no list model set. In the Gtk4 docs the model is set by the constructor from the provided list of strings. Do you have a model property defined in your XML file for the dropdown widget? There’s an example here: Gtk.DropDown

Dear jwahlstrand,

Thank you! That was the source of the problem. :slight_smile:
I didn’t want to fill the dropdown menu in XML but rather from Julia because I had a matrix filled with data. That’s why I didn’t think about setting the model property in the XML file.

Thanks again!