add completer to gtk cellrenderercombo

19 views Asked by At

Is there a way to add a completer to gtk cellrenderercombo? I know you can with a regular combobox. I have been updating the old griffith movie database and need this for the languages.

This is what I tried.

model = self.lang['lang'] = Gtk.ListStore(int, str)
for i in self.db.session.query(db.Lang.lang_id, db.Lang.name).all():
    model.append([i.lang_id, i.name])

combo = Gtk.CellRendererCombo()
combo.set_property('model', model)
combo.set_property('text-column', 1)
combo.set_property('editable', True)
combo.set_property('has-entry', True)
combo.connect('edited', self.on_tv_lang_combo_edited, 0)
completer = Gtk.EntryCompletion()
completer.set_model(combo.get_model())
completer.set_text_column(0)
combo.get_child().set_completion(completer)
column = Gtk.TreeViewColumn(_('Language'), combo, text=0)
column.set_property('min-width', 80)
column.set_property('resizable', True)
column.set_sort_column_id(0)
treeview.append_column(column)
0

There are 0 answers