Hello Monks,

I'm writing a small Tk app to list an MP3 collection and allow searching. I'm doing this to learn some Tk.

I am displaying the results in a Tk::Table, but the problem is that I'm not finding anywhere in the documentation how to reset the table to display new results.

The approach I'm using now is that I'm placing empty strings in the fields, and then filling in the results. But that's plain wrong. Because, say after a search that displayed 20 results, the next search that will display for example 4 results, will display 4 rows of results, and 16 empty rows.

my $table = $window->Table( -rows => 20, -columns=> 4, -fixedrows=>1, -takefocus=>1)->pack; $table->put(0,0,'Title'); $table->put(0,1,'Artist'); $table->put(0,2,'Album'); $table->put(0,3,'CD'); # later on... sub show_results { # clean up table. for my $i (1..$table->totalRows) { for my $j (0..3) { $table->put($i,$j,''); } } my $b = $window->Balloon(); # fill the new data. my $i = 0; foreach (keys %db) { if ($db{$_} =~ /$searchpattern/i) { my ($file, $location, $title, $artist, $album, $cd) = split /\n/, $db{$_}; my $l = $table->Label(-text=>$title); $b->attach($l, -balloonmsg=>$_); $table->put($i, 0, $l); $table->put($i, 1, $artist); $table->put($i, 2, $album); $table->put($i, 3, $cd); $i++; } } }

Is there a way to remove rows from a Tk::Table? Should I be deleting the table altogether and redrawing it? Or should I be using something completely other than the Tk::Table to display the data?


In reply to removing rows from a Tk::Table by Anonymous Monk

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.