Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: removing rows from a Tk::Table
by PodMaster (Abbot) on Sep 12, 2004 at 10:56 UTC | |
by qumsieh (Scribe) on Sep 12, 2004 at 14:58 UTC | |
by Courage (Parson) on Sep 12, 2004 at 15:47 UTC |