Gtk2::Liststore multiple columns



Hello,

I want to create a list with multiple columns. Therefore I use the script added below (actually there are 8 columns, but I reduced them to make it less complicated). The subroutine &abfrage_all returns an array with references to arrays. Each referred array is a row in a database. I now want to put each row from the database into my list. But what I get is that in each column of one row the value of the first column is put (i.e. $zeile[0] in columns 1 to 8):

my $model = Gtk2::ListStore -> new('Glib::String','Glib::String');
my $tree = Gtk2::TreeView -> new_with_model($model);

# create columns
my @Beschriftung = ('Name', 'Vorname');
for (my $i = 0; $i < (@Beschriftung); $i++){
$col[$i] = Gtk2::TreeViewColumn -> new_with_attributes($Beschriftung[$i],Gtk2::CellRendererText->new, text => 0);
   $tree -> append_column($col[$i]);
}

# Array with references on arrays (each a row in database)
my @addr = &abfrage_all("*","Adressen","InhaberID >",-1);

#  put arrays into list
foreach (@addr){
   my @zeile = @$_;
   my $iter = $model -> append();
   for (my $i = 0; $i < (@zeile); $i++){
       $model -> set($iter,$i,$zeile[$i]);
   }
}

If I replace the for-loop only by:
$model -> set($iter,0,$zeile[0]);

already in each column appears the value $zeile[0].

If replaced by:
$model -> set($iter,1,$zeile[0]);

All the columns (i.e the whole list) remain empty.
Can someone help me to do it right?
Thanks
Mario



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