Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Your welcome. After posting that example code, I extended it to multicolumn sorting. You may find this example even better. It sorts on each column, by clicking that column header.
#!/usr/bin/perl use warnings; use strict; use Gtk2 -init; use Gtk2::SimpleList; 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'], [41, + '4text'] ); $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); $slist->get_column(0)->signal_connect( clicked => sub { warn "clicked 0!\n" } ); $slist->get_column(1)->signal_connect( clicked => sub { warn "clicked 1!\n" } ); $vbox->add ($slist); my $button = Gtk2::Button->new('Show Data'); $vbox->pack_end( $button, 0, 0, 0 ); $button->signal_connect( clicked => sub { print @{$slist->{data}},"\n"; # demonstrates reordering foreach my $arr ( @{$slist->{data}} ){ print "$arr->[0]\t$arr->[1]\n" } print "\n\n"; } ); $win->show_all; Gtk2->main;

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

In reply to Re^3: Sortable table using Gtk2 in UI application by zentara
in thread Sortable table using Gtk2 in UI application by SyneRohit

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-03-19 05:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found