in reply to Sortable table using Gtk2 in UI application
Here is a simpler way to sort a list, using SimpleList. There are other ways too.
I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh
#!/usr/bin/perl use warnings; use strict; use Gtk2 -init; use Gtk2::SimpleList; # click on the "int" column header to sort on it my $win = Gtk2::Window->new; $win->signal_connect (delete_event => sub { Gtk2->main_quit; }); my $vbox = Gtk2::VBox->new; $win->add ($vbox); my $slist = Gtk2::SimpleList->new ( 'Int' => 'int', 'Text' => 'text' ) +; @{$slist->{data}} = ( [11, 'text1'], [21, 'text2'], [3, 'text3'] ); $slist -> set_reorderable( 1 ); #my @columns = $slist->get_columns; #for (my $i = 0 ; $i < @columns ; $i++) { #$columns[$i]->set_sort_column_id ($i); #} # or $slist->get_column (0)->set_sort_column_id (0); #$slist->get_column (1)->set_sort_column_id (1); #in case you want to catch the sort occuring $slist->get_column(0)->signal_connect( clicked => sub { warn "clicked!\n" } ); $vbox->add ($slist); $win->show_all; Gtk2->main;
I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Sortable table using Gtk2 in UI application
by SyneRohit (Initiate) on Oct 03, 2011 at 10:10 UTC | |
by zentara (Archbishop) on Oct 03, 2011 at 12:15 UTC |
In Section
Seekers of Perl Wisdom