Set default item Gtk.ComboBoxText?

I would like to make the item in my ComboBoxText the default and not an empty combo box until the user selects anything. Apparently, this is set by changing the active value in Glade to [the element I want by default]. This does not work.

Here is my code:

#! /usr/bin/env python3 from gi.repository import Gtk builder = Gtk.Builder() builder.add_from_file("./personalinfo.ui") win = builder.get_object("window") cancel = builder.get_object("cancel") ok = builder.get_object("ok") win.set_title("Persona") win.connect("destroy", Gtk.main_quit) cancel.connect("clicked", Gtk.main_quit) ok.connect("clicked", Gtk.main_quit) win.show_all() Gtk.main() 

Here is the combo box in Glade:

comboboxtext

+4
source share
1 answer

This is actually a bug in Glade. You can manually install this using:

 combo.set_active(int) # 1st item is 0, 2nd is 1, etc. 
+8
source

All Articles