[Glade-users] combobox question




OK, I just tried a simple example first, but it gives me a warning:
Here is my Python code for filling in comboBox, etc. :
 
store = gtk.ListStore(str)
 
store.append(["test1"])
store.append(["test2"])
store.append(["test3"])
store.append(["test4"])

combo = wtree.get_widget('myComboBoxFromGlade')
combo.set_model(store)
if  type(combo) == gtk.ComboBoxEntry :
      combo.set_text_column(0)   ### this gives me a warning, see bellow !!!!!!
elif   type(combo) == gtk.ComboBox :
      cell = gtk.CellRendererText()
      combo.pack.start(cell, True)
      combo.add_attribute(cell, 'text', 0)
 
At run time, my combo box seem to function OK, but I get this warning:
GtkWarning: gtk_combo_box_entry_set_text_column: assertion `entry_box->priv->text_column == -1' failed 
combo.set_text_column(0)
 
Why does this warning comes up, should I be worried about it and is there a way to fix it?
Thanks,
Arthur.
 
Date: Thu, 23 Sep 2010 18:35:55 +0100
Subject: Re: [Glade-users] combobox question
From: johndelaney at gmail.com
To: ashats at hotmail.com
CC: glade-users at lists.ximian.com

On Thu, Sep 23, 2010 at 6:20 PM, Arthur Shats <ashats at hotmail.com> wrote:
I am not familiar with TreeModel. Does it mean I have to create a treeview
widget in Glade instead of a combobox widget?

No. TreeModel is an interface that is implemented by TreeStore and
ListStore; you'll probably want to use the latter. You can create a
ListStore in Glade, populate it, create a TreeModelFilter, set its
child model as your ListStore, and then set the TreeModelFilter as the
model of your ComboBox. Personally I prefer to create my data
structures / models in code, though.

Also, in my other combo box I have items that represent countries, so each
item has a country code and its name beside it, like this:
AG Argentina
AU Austria
BR Brazil
FR France
Of course, when item is selected I want to display the country name in the
box, without the country code. I have a feeling I need to use TreeModel for
this as well, right? No idea how to do this. Any hints/examples will be
appreciated.

By using more than one cell renderer, perhaps?
                                          
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/glade-users/attachments/20100923/e40ed8e6/attachment.html 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]