我编写了简单的Perl/Tk应用程序,我需要将二维数组看作一个网格,例如德尔福的StringGrid。但是我找不到类似于StringGrid的Tk小部件。有类似的小部件吗?
发布于 2014-03-19 17:08:35
是的,有一个类似StringGrid的部件。有两个模块可以用于此。1号和数字2.我认为Nr1是你要找的。
下面是一个简单使用的简短示例:
use strict;
use warnings;
use Tk;
use Tk::TableMatrix::Spreadsheet;
my $mw = Tk::MainWindow->new(-width => 380, -height => 400,);
$mw->packPropagate(0);
my %table = ();
my $t = $mw->Scrolled(
'Spreadsheet',
-cols => 4,
-rows => 500,
-width => 4,
-titlerows => 1,
-titlecols => 0,
-variable => \%table,
-selectmode => 'extended',
-titlerows => 1,
-titlecols => 1,
-bg => 'white',
-bg => 'white',
-scrollbars => 'se',
);
my $l = $t->Label(-text => 'text',);
$t->set('1,2', "Name");
for( my $c = 0; $c < 500; $c++ ) {
$t->set("$c,0", $c);
$t->set("$c,1", $c*100);
$t->set("$c,2", $c^17);
$t->set("$c,3", $c/5);
}
$t->pack(-fill => 'both', -expand => 1);
$mw->MainLoop();https://stackoverflow.com/questions/22512585
复制相似问题