Ohad has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I got a table, I'm using Tk::Table. I want to support filtering. For that I wanted to use some sort of hide like in Hlist, but I can't find that subroutine in Tk:Table, do you know if something like hide exists?

Replies are listed 'Best First'.
Re: Tk::Table hide?
by sierpinski (Chaplain) on Jul 12, 2010 at 11:32 UTC
    Have you searched the CPAN POD? Have you googled?

    Where have you looked? What have you tried? Are you asking the right question? Sometimes saying what you're trying to do is more effective than asking about a particular function, because it may end up that there's another way to achieve your goal than what you think.
      Hi,

      I want to create a table in Perl Tk, that will support sort and filtering.

      Currently I implemented the table using Tk::Table. This is the table code:
      my @lines = (<Tab>); chomp(@lines); close(Tab); my @tmp = (split(/;/,$lines[0])); my $colu = ($#tmp) +2; my $ro = ($#lines+2); $table->destroy if ($table); $table = $TFrame->Table(-rows=>$ro, -columns=>$colu, - +scrollbars=>'se', -fixedrows=>2, -relief=>'raised')->pack(-side=>'top +',-anchor=>'nw'); my $r =1; my @Approved =0; foreach my $row (@lines) { my $tmp_l; if ($r>1) { my $data = $r -1; $tmp_l = $table->Label(-text=>$data, -anchor=> +'w', %Entry_color, -relief=>"groove"); $table->put($r, 1, $tmp_l); } else { $tmp_l = $table->Label(-text=>"Entry", -anchor +=>'w',-background=>'gray', -relief=>"raised"); $table->put($r, 1, $tmp_l); } my $c=2; my @data = (split(/;/,$row)); while ($c <= $colu) { if ($data[$c-2]) { $file_Contant[$r-1][$c-2]=$data[$c-2] ; } else { $file_Contant[$r-1][$c-2]=""; } my $tmp_label; if ($r==1) { $tmp_label = $table->Label(-text=>$data[$c +-2], -anchor=>'w',-background=>'gray', -relief=>"raised") ; + } $tmp_label = $table->Entry(-textvariable => \$ +file_Contant[$r-1][$c-2], -width=> 15,%Entry_color, -relief=>"groove" +) if ($r>1); $table->put($r, $c, $tmp_label); $c++; } $r++; } $table->pack(-fill=>'both',-side=>'top',-anchor=>'nw', +-expand=>1); return($table,\@file_Contant) }

      I want to create filtering according to columns.

        I mean e.g. filtering "Perl" in column 8, then show all rows that has "Perl" in column 8, only. I did google, and looked at the CPAN.
Re: Tk::Table hide?
by hangon (Deacon) on Jul 13, 2010 at 05:46 UTC