1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| #!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Tk::BrowseEntry;
use Tk::TableMatrix;
my $top = MainWindow->new;
my $arrayVar = {};
foreach my $row ( 0 .. 20 ) {
foreach my $col ( 0 .. 10 ) {
$arrayVar->{"$row,$col"} = "r$row, c$col";
}
}
my $t = $top->Scrolled(
'TableMatrix',
-rows => 21,
-cols => 11,
-width => 6,
-height => 6,
-titlerows => 1,
-titlecols => 1,
-variable => $arrayVar,
-selectmode => 'extended',
-resizeborders => 'both',
-titlerows => 1,
-titlecols => 1,
-bg => 'white',
);
$t->tagConfigure( 'active', -bg => 'red', -relief => 'sunken' );
$t->tagConfigure( 'title', -bg => 'blue', -fg => 'black', -relief => 'sunken' );
################ Put in some embedded windows ################
my $l = $top->Checkbutton( -text => 'CheckButton' );
$t->windowConfigure( "3,3", -sticky => 's', -window => $l );
my $c = $top->BrowseEntry( -label => "Month:" );
$c->insert( "end", "January" );
$c->insert( "end", "February" );
$c->insert( "end", "March" );
$c->insert( "end", "April" );
$c->insert( "end", "May" );
$c->insert( "end", "June" );
$c->insert( "end", "July" );
$c->insert( "end", "August" );
$c->insert( "end", "September" );
$c->insert( "end", "October" );
$c->insert( "end", "November" );
$c->insert( "end", "December" );
$t->windowConfigure( "2,2", -sticky => 'ne', -window => $c );
# Leave enough room for the windows
$t->colWidth( 2, 20 );
$t->colWidth( 3, 20 );
$t->pack( -expand => 1, -fill => 'both' );
MainLoop; |
Partager