Olivier
11/26/2006 2:35:00 PM
> I created an instance of ListStore and added a row. I see the row, and
> I'm able to click on the row (the row change the color) but i don't see
> any text in the cells. Does anyone have an idea how to fix it?
Try to replace these lines :
> column = Gtk::TreeViewColumn.new("Foo", renderer)
> column = Gtk::TreeViewColumn.new("Bar", renderer)
> column = Gtk::TreeViewColumn.new("Mix", renderer)
by these :
column = Gtk::TreeViewColumn.new("Foo", renderer, :text => 0)
column = Gtk::TreeViewColumn.new("Bar", renderer, :text => 1)
column = Gtk::TreeViewColumn.new("Mix", renderer, :text => 2)
This is the easy way to affect the content of a column to the data stored in
the model. The last argument of the TreeViewColumn constructor is a hash of
attributes which define a mapping between the data in the model, and what
will appear in the TreeView (those attributes can be reaffected later with
#add_attribute or #set_attributes)
In your case, you created this model :
> iter[0] = "First"
> iter[1] = "Second"
> iter[2] = "Third"
The attribute {:text => 0} means "I want to map directly the content of
iter[0] to the rendered text of the "Foo" column".
Another way to do this is by using the #set_cell_data_func method, which let
you define the rendering of the cell from the given block (using
CellRenderer#text=, for example)