in reply to Re^3: Tk ::TableMatrix
in thread Tk ::TableMatrix
#!/usr/bin/perl use Tk; use Tk::TableMatrix; my $mw = MainWindow->new; my $arrayVar = {}; print "Filling Array...\n"; my ($rows,$cols) = (10, 10); foreach my $row (1..($rows-1)){ foreach my $col (0..($cols-1)){ $arrayVar->{"$row,$col"} = 2*$row + 3*$col; } } print "Creating Table...\n"; ## Test out the use of a callback to define tags on rows and columns sub colSub{ my $col = shift; return "OddCol" if( $col > 0 && $col%2) ; } my $t = $mw->Scrolled('TableMatrix', -rows => $rows, -cols => $cols, -width => 10, -height => 10, -titlerows => 1, -titlecols => 1, -variable => $arrayVar, -coltagcommand => \&colSub, -browsecommand => \&brscmd, -colstretchmode => 'last', -rowstretchmode => 'last', -selectmode => 'extended', -selecttitles => 0, -drawmode => 'slow', -scrollbars=>'se' ); $mw->Button(-text => "Add", -command => \&add_row) ->pack(-side => 'bottom',-anchor => 'w'); sub add_row { ++$x; my ($rows,$cols) = (10+$x, 10); foreach my $row (1..($rows-1)){ foreach my $col (0..($cols-1)){ $arrayVar->{"$row,$col"} = 2*$row + 3*$col; } } my $t = $mw->Scrolled('TableMatrix', -rows => $rows, -cols => $cols, -width => 10, -height => 10, -titlerows => 1, -titlecols => 1, -variable => $arrayVar, -coltagcommand => \&colSub, -browsecommand => \&brscmd, -colstretchmode => 'last', -rowstretchmode => 'last', -selectmode => 'extended', -selecttitles => 0, -drawmode => 'slow', -scrollbars=>'se' ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Tk ::TableMatrix
by zentara (Cardinal) on Jul 15, 2008 at 16:28 UTC | |
by lil_v (Sexton) on Jul 17, 2008 at 15:41 UTC | |
by zentara (Cardinal) on Jul 17, 2008 at 17:19 UTC |