Debian Codegraph @

TixGrid/tgdemo_config

raw
1 #!/usr/local/bin/perl -w
2 # tixgrid demo
3 # standalone or sourceable in ptksh
4
5 ### Bugs: o shouldn't size(dim, idx, -size=>3) mean 3 chars????
6 ### o $tg->sizeColumn( 'default', -size=>'1c')
7 ### does resize all but the 0th column
8 ### o -widthi=>num is in # of columns (not chars) so should
9 ### not be in standard options
10
11 use strict;
12
13 use Tk ();
14 use Tk::Text;
15 use Tk::TixGrid;
16
17 use vars qw($mw $demo $tg $log);
18
19 my $inPtksh = defined $mw;
20 if ($inPtksh)
21 {
22 print "\$demo=demoframe \$tg=tixgrid \$log =text log\n";
23 $demo->destroy if defined($demo);
24 }
25 else
26 {
27 require Tk::ErrorDialog;
28 $mw = Tk::MainWindow->new();
29
30
31 }
32 $demo = $mw->Frame(-background=>'red')->pack(-expand=>'yes', -fill=>'both');
33
34 $tg = $demo->Scrolled('TixGrid',
35 #$tg = $demo->TixGrid(
36 -leftmargin=>0,
37 -topmargin=>1,
38 -width=>2, # in # of columns
39 ) ->pack(-expand=>'yes',-fill=>'both');
40
41 my $heads = [ qw(Option Name Class Default Value) ];
42 my ($i,$j) = (0,0);
43 my @colmap = (0,2,3,4,1);
44 foreach my $o ($heads, $tg->configure)
45 {
46 next if scalar(@$o) == 2; # ignore aliases
47 foreach my $v (@$o)
48 {
49 $tg->set($colmap[$i],$j, -text=>$v);
50 $i++;
51 }
52 $j++;
53 $i=0;
54 }
55 $tg->sizeColumn('default', -size=>'auto');
56
57
58 $log = $demo->Text(-width=>50, -height=>5)->pack(-fill=>'x');
59 sub Log
60 {
61 my $val;
62 foreach (@_)
63 {
64 $log->insert('end', (defined($_) ? "$_|" : "(undef)|") );
65 }
66 $log->insert('end',"\n");
67 $log->see('end');
68 1;
69 }
70
71 $tg->configure(
72 -editdonecmd => [\&Log, 'editDoneCmd ='],
73 -editnotifycmd => [\&Log, 'editNotifyCmd='],
74 -formatcmd => [\&Log, 'formatCmd ='],
75 );
76
77 $tg->focus;
78 Tk::MainLoop unless $inPtksh;
79
80 __END__