File: tgdemo_config

package info (click to toggle)
perl-tk 1%3A804.030-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 33,712 kB
  • sloc: ansic: 349,532; perl: 51,961; sh: 17,904; makefile: 5,730; asm: 3,565; ada: 1,681; pascal: 1,089; cpp: 1,006; yacc: 883; cs: 879
file content (80 lines) | stat: -rwxr-xr-x 1,694 bytes parent folder | download | duplicates (10)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/local/bin/perl -w
# tixgrid demo
#	standalone or sourceable in ptksh

### Bugs:	o shouldn't size(dim, idx, -size=>3) mean 3 chars????
###		o $tg->sizeColumn( 'default', -size=>'1c')
###		  does resize all but the 0th column
###		o -widthi=>num is in # of columns (not chars) so should
###		  not be in standard options

use strict;

use Tk ();
use Tk::Text;
use Tk::TixGrid;

use vars qw($mw $demo $tg  $log);

my $inPtksh = defined $mw;
if ($inPtksh)
  {
    print "\$demo=demoframe   \$tg=tixgrid   \$log =text log\n";
    $demo->destroy if defined($demo);
  }
else
  {
    require Tk::ErrorDialog;
    $mw = Tk::MainWindow->new();


  }
$demo = $mw->Frame(-background=>'red')->pack(-expand=>'yes', -fill=>'both');

$tg = $demo->Scrolled('TixGrid',
#$tg = $demo->TixGrid(
		-leftmargin=>0,
		-topmargin=>1,
		-width=>2,	# in # of columns
		) ->pack(-expand=>'yes',-fill=>'both');

my $heads = [ qw(Option Name Class Default Value) ];
my ($i,$j) = (0,0);
my @colmap = (0,2,3,4,1);
foreach my $o ($heads, $tg->configure)
  {
    next if scalar(@$o) == 2; # ignore aliases
    foreach my $v (@$o)
      {
	$tg->set($colmap[$i],$j, -text=>$v);
	$i++;
      }
    $j++;
    $i=0;
  }
$tg->sizeColumn('default', -size=>'auto');


$log = $demo->Text(-width=>50, -height=>5)->pack(-fill=>'x');
sub Log
  {
    my $val;
    foreach (@_)
      {
         $log->insert('end', (defined($_) ? "$_|" : "(undef)|") );
      }
    $log->insert('end',"\n");
    $log->see('end');
    1;
  }

$tg->configure(
	-editdonecmd   => [\&Log, 'editDoneCmd  ='],
	-editnotifycmd => [\&Log, 'editNotifyCmd='],
	-formatcmd     => [\&Log, 'formatCmd    ='],
	);

$tg->focus;
Tk::MainLoop unless $inPtksh;

__END__