hanspr has asked for the wisdom of the Perl Monks concerning the following question:
my $slist = Gtk3::SimpleList->new ( 'Text Field' => 'text', 'Markup Field' => 'markup', 'Int Field' => 'int', 'Double Field' => 'double', 'Bool Field' => 'bool', 'Scalar Field' => 'scalar', 'Pixbuf Field' => 'pixbuf', );
# just displays the value in a scalar as # Perl would convert it to a string Gtk3::SimpleList->add_column_type( 'a_scalar', type => 'Glib::Scalar', renderer => 'Gtk3::CellRendererText', attr => sub { my ($treecol, $cell, $model, $iter, $col_num) = @_; my $info = $model->get ($iter, $col_num); $cell->set (text => $info); } ); # sums up the values in an array ref and displays # that in a text renderer Gtk3::SimpleList->add_column_type( 'sum_of_array', type => 'Glib::Scalar', renderer => 'Gtk3::CellRendererText', attr => sub { my ($treecol, $cell, $model, $iter, $col_num) = @_; my $sum = 0; my $info = $model->get ($iter, $col_num); foreach (@$info) { $sum += $_; } $cell->set (text => $sum); } );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Gtk3::SimpleList create personal type with 2 cells in same column
by Anonymous Monk on Jan 09, 2020 at 00:20 UTC | |
by hanspr (Sexton) on Jan 31, 2020 at 06:15 UTC | |
|
Re: Gtk3::SimpleList create personal type with 2 cells in same column
by hanspr (Sexton) on Jan 31, 2020 at 06:12 UTC | |
|
Re: Gtk3::SimpleList create personal type with 2 cells in same column
by hanspr (Sexton) on Feb 01, 2020 at 16:17 UTC |