Files
2024-10-14 00:08:40 +02:00

53 lines
1.3 KiB
Perl

#! /usr/bin/perl
use warnings;
use strict;
use Tk;
use Tk::Table;
my $mw = new MainWindow;
my $top = $mw->Table(-rows => 2, -columns => 2);
foreach my $r (0..1) {
foreach my $c (0..1) {
$top->put($r,$c,"$r,$c");
}
}
my $button = $mw->Button(-text => 'Resize', -command => [\&resize_, $top]);
$button->grid (-row=>1, -column=>1);
$top->grid (-row=>2, -column=>1);
MainLoop;
sub resize {
my ($table) = @_;
print "old table dimensions: ",
$table->totalRows, " rows and ",
$table->totalColumns, " columns\n";
$table->configure(-rows => 5, -columns => 5);
print "new table dimensions: ",
$table->totalRows, " rows and ",
$table->totalColumns, " columns\n";
}
# Try filling the new area in:
sub resize_ {
my ($table) = @_;
print "old table dimensions: ",
$table->totalRows, " rows and ",
$table->totalColumns, " columns\n";
$table->configure(-rows => 5, -columns => 5);
foreach my $r (2..4) {
foreach my $c (2..4) {
$table->put($r,$c,"$r,$c");
}
}
$table->put(1,1,"KUCK");
print "new table dimensions: ",
$table->totalRows, " rows and ",
$table->totalColumns, " columns\n";
}