Hello everyone..!

I'm having a problem with gtk.ListStore class, while i'm trying to insert values into it.
It seems that after I create the class object and use each one of the functions which responsible for values insertion (insert, append, prepend etc...), the only value that gets inserted to the list is None!

e.g:

listStore = gtk.ListStore(str, int)
listStore.insert(0, )
comboBoxEntry = gtk.ComboBoxEntry(listStore)

The comboBoxEntry objects displays an empty row instead of the row inserted!

any ideas ??

Dani AI

Generated

Good find by — the blank/None-looking row usually means the ComboBox’s renderer wasn’t told which model column holds the display text, not that the ListStore failed to get values. The ComboBox will happily hold rows but show nothing unless you either map a renderer’s "text" attribute to a model column or use the ComboBox/entry helper that knows which column to display.

Quick checklist to diagnose the model itself:

  • Confirm you actually inserted values for every declared column and in the right order. Mismatched counts can leave None in a column.

  • Walk the model to inspect stored values before worrying about the widget. For example:

    iter = liststore.get_iter_first()
    while iter is not None:
        print(liststore.get_value(iter, 0), liststore.get_value(iter, 1))
        iter = liststore.iter_next(iter)

Renderer/mapping options (alternate to telling the ComboBox which column to use):

  • Attach a CellRendererText to the ComboBox and map its "text" attribute to the appropriate column index with add_attribute (this explicitly links model column -> visible text).
  • For simple, static string lists the popdown-strings approach (as mentioned) bypasses a model entirely and is convenient.

A few practical notes:

  • Make sure the types you declared for the ListStore match what you insert (string vs integer) — wrong types can be a source of subtle problems.
  • If you want an initial visible value, set the combo’s active item explicitly after populating.
  • If moving to newer GTK bindings, ComboBoxEntry has been superseded by combos-with-entry or EntryCompletion; APIs differ, so adjust the mapping approach accordingly.

These checks usually find the cause quickly: either the model contains unexpected None values, or the combo simply has no mapping from model column to renderer.

Recommended Answers

All 4 Replies

I thought you loaded the combobox this way:

comboBoxEntry.entry.set_text("String1")

# or
slist = [ "String1", "String2", "String3", "String 4" ]

comboBoxEntry.set_popdown_strings(slist)

Was this of any help?

Still trying to get GTK to go on my Windows Box.

The command i forgot was :

comboBoxEntry.set_text_column(0)

after that, the text shuold appear in the combo box.
It works on Linux, I think it should work on Windows too...

Thanks Avner,

the gtk GUI sounds interesting. I make sure my next computer is a Linux machine!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.