R – How to use/fill a combo box with Ruby/Glade 3

comboboxgladeruby

I am trying to make a gui with Glade 3 (gtk) and ruby but cannot figure out how to actually populate a combo box dynamically with say a list of strings. I get the xml .glade file after i visually make my gui in Glade, and use ruby-glade-create-template to generate my .rb file but have no idea where to go from here. I cannot find any guides on how to use ruby with Glade 3 and any help would be appreciated. Thanks!

Best Answer

Why do you need to generate a .rb file? Code generation is Frowned Upon™. So do you load the glade file with a Gtk::Builder instance? Once you have the Builder object you call the get_object method to get specific widgets.

Here is a pretty good tutorial on glade 3, it doesn't cover ruby but python is close enough. It is a little dated so some bugs mentioned there have been fixed if you are using a recent version of glade 3.