Hi All,
I've built a gtk window interface in glade using the gtkbuilder
format. It contains a combobox which I need to populate "on the fly"
ie as part of the object initialisation, but I can't get it to display
any entries.

Searching has revealed a lot of people having difficulty with it -
there are a lot of suggested resolutions, none of which have worked
for me (yet) -

My example code looks like:
================
#!/usr/bin/env python

import gobject, gtk
import os, sys

class Combos:

    def delete_event(self, widget, event, data=None):
        return False

    def destroy(self, widget, data=None):
        gtk.main_quit()

    def __init__(self):

        builder = gtk.Builder()
        builder.add_from_file("cboxdebug.xml")

        self.window = builder.get_object("window1")
        builder.connect_signals(self)
        self.window.connect("delete_event", self.delete_event)
        self.window.connect("destroy", self.destroy)

        # populate combobox1
        self.combobox1 = builder.get_object("combobox1")
        liststore = gtk.ListStore(gobject.TYPE_STRING)
        self.combobox1.set_model(liststore)
        cell = gtk.CellRendererText()
        self.combobox1.pack_start(cell, True)
        dynentries = ['foo1', 'foo2', 'foo3']
        for entry in dynentries:
            self.combobox1.add_attribute(cell, entry, 0)
        #self.combobox1.get_row_span_column()
        #self.combobox1.get_column_span_column()

    def main(self):
        gtk.main()

if __name__ == "__main__":
    combos = Combos()
    combos.window.show()
    combos.main()

================


When I run it, the combobox is greyed out. There is no error/debug output.

I've tried setting the Row Span Column and Column Span Column values >
-1 in the glade designer, and the output I get is:
================
cboxdebug.py:17: GtkWarning: gtk_tree_model_get_n_columns: assertion
`GTK_IS_TREE_MODEL (tree_model)' failed
  builder.add_from_file("cboxdebug.xml")
cboxdebug.py:17: GtkWarning: gtk_combo_box_set_row_span_column:
assertion `row_span >= -1 && row_span < col' failed
  builder.add_from_file("cboxdebug.xml")
cboxdebug.py:17: GtkWarning: gtk_combo_box_set_column_span_column:
assertion `column_span >= -1 && column_span < col' failed
  builder.add_from_file("cboxdebug.xml")
================

I assume I need to make use of the set_row_span_column() and
set_column_span_column() functions but I cannot get a clear indication
of what they do/how to use them.

I've also seen mention that populating the combobox in glade designer
with a None entry helps, however this option is listed as a libglade
format thing only and the option is greyed out in the designer (I'm
using what I understand is the newer/better gtkbuilder format).

Can somebody give me a clue about how to make this work?

Thanks,
Bernie
_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to