in reply to Re^5: Tk ::TableMatrix
in thread Tk ::TableMatrix
#!/usr/bin/perl use warnings; use strict; use Tk; require Tk::TableMatrix; require Tk::Pane; my $mw = MainWindow->new; my $arrayVar = {}; my $t; $mw->Button(-text => "Create Table", -command => \&create_table)->pack +(); sub create_table { # usage programname rows cols my ( $rows, $cols ) = @ARGV; #Then you could test if anything passed: if ( !defined $rows ) { $rows = 4 } if ( !defined $cols ) { $cols = 4 } my $mw = tkinit; $mw->geometry('400x400'); my $tp = $mw->Scrolled('Pane', -sticky => 'nw', )->pack( -fill =>'both', -expand => 1, ); my $bf = $mw->Frame()->pack(); my $t = $tp->TableMatrix( -cols => $cols, -rows => $rows, )->pack(-fill =>'both', -expand => 1 ); $bf->Button(-text=> 'add column', -command=>sub{$t->packPropagate(1); $t->insertCols(0,1); $mw->update; }, )->pack(-side => 'left'); $bf->Button(-text=> 'add row', -command=>sub{$t->packPropagate(1); $t->insertRows(0,1); $mw->update; }, )->pack(-side => 'right'); } MainLoop;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Tk ::TableMatrix
by zentara (Cardinal) on Jul 17, 2008 at 17:19 UTC |