As Mr. Spock would say... fascinating. Much appreciated, Athanasius. Your modification works for me as well, even on an older version of Tk. That solves the problem for my original post.
The real reason I have the sub is that I also need the number of rows to vary each time I click the button. So, the OP was reduced too much. Thanks to your recommendation, my more realistic code below works also. I happen to know up front that the maximum number of rows is a constant (32):
use warnings; use strict; use Tk; use Tk::Table; my $mw = MainWindow->new(); my $upper = $mw->Frame()->pack(-side => 'top'); my $but1 = $upper->Frame()->pack(); my $lower = $mw->Frame()->pack(-side => 'bottom'); my $table = $lower->Table(-rows => 32, -columns => 5)->pack; upd_table(); $but1->Button( -text => 'update', -command => sub { upd_table() }, )->pack(); MainLoop(); exit; sub upd_table { $table->clear() if $table; my $r = 3 + int rand 3; foreach my $row ( 0 .. $r-1 ) { foreach my $col ( 0 .. 4 ) { my $x = int rand 10; my $cell = $table->Entry( -width => 4, -text => $x ); $table->put( $row, $col, $cell ); } } }
It would be helpful if another Monk could explain this behavior and suggest a better method.
In reply to Re^2: Tk::Table clear creates unwanted boxes
by toolic
in thread Tk::Table clear creates unwanted boxes
by toolic
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |