Code Comments
Programming Forum and web based access to our favorite programming groups.This is a multi-part message in MIME format.
--------------020600020800000900040004
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Hello,
I have a Perl/Tk gui for allowing user editing of land grid data, which
consists of a fixed length header, and a variable length polygon. Most
of the polygons are less than 100 points, but a few are between 1000 and
3000 points. Even the largest load properly into the Pane (slowly, but
properly), but if the polygon exceeds 1438 points, you cannot scroll
beyond the 1438th point.
I have attached a sample script that demonstrates the problem. You can
supply --npp=nnn on the command line to experiment.
I have tried it on Perl 5.6.1 and Perl 5.8.0 (both on Linux); I don't
know how to tell what version of Tk I have.
Thank you for your assistance on this problem.
Don
--------------020600020800000900040004
Content-Type: text/plain;
name="tk_prob.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="tk_prob.pl"
#!/usr/bin/perl
use Tk;
use Tk::Pane;
use Getopt::Long;
#
# --npp=num polygon points
#
GetOptions("npp=s"=>\$npp);
print "npp=$npp\n";
#
# initialize
#
if (!$npp) {$npp=1450;}
print "npp=$npp\n";
$mw = MainWindow->new;
$mw->title("LgTx Edit");
$mw->bind('all','<Return>','focusNext');
# start new frame
$fr1=$mw->Frame;
$fr1->pack(-anchor=>'w');
# define lengths and names of fields
@fieldlen=(7,3,2,3,1,4,9,9,9,9,9,9,6,2,1
,1,8,1,5,4,9,9,1,7,7,1,5,4,
9,9,32,32,1,5,4,9,9,5,1,5,4,9,9,17,1,5,4
,9,9,3,4);
@fieldnam=('quad','tract','state','cnty'
,'gloTr','orig_sc','cntr_lat',
'cntr_lon','min_lat','min_lon','max_lat'
,'max_lon',
'rev_date','spczone','sbc','slp','sub_nu
m','ann_sub',
'asn_size','asn_ang','asn_lat','asn_lon'
,'blt',
'blr_num','twnshp','ann_blr','abn_size',
'abn_ang',
'abn_lat','abn_lon','survey_name','surve
y_name_plot',
'ann_svy','asvn_size','asvn_ang','asvn_l
at','asvn_lon',
'abstract','ann_abs','aan_size','aan_ang
','aan_lat',
'aan_lon','misc_text','ann_mt','amt_size
','amt_ang',
'amt_lat','amt_lon','num_parts','num_poi
nts');
#
# calculate total length of o/p strings (labels+entries)
#
$tot_sumfl = 0;
foreach $fl (@fieldlen) {$tot_sumfl= $tot_sumfl + $fl;}
foreach $fl (@fieldnam) {$tot_sumfl= $tot_sumfl + length($fl);}
#
# create toplevel window if it does not exist
#
if (!Exists($tl)) {
$tl = $mw->Toplevel();
$tl->title("LgTxData");
}
#
# dummy data
@row=('576 NE',002,42,389,'Y',24000,31.3853.103.357,31.375,103.347,31.3938,1
03.366,'031794',03,'S',' S' , 6 ,' Y' , 00240
, 0345 , 31.3908 , 103.348 ,'B' , 'C7' , , 'N'
, 00240 , 0000 ,
31.3871 , 103.357 , 'PSL' , 'PSL' , 'N' , 00240 ,
0000 , 31.3853 , 103.357 , 4878 , 'N' , 00240 , 000
0 , 31.3835 , 103.357 , , 'N' , 00240 , 0000 , 31.38
17 , 103.357 , 0
, 9);
#
# build well display with frames
# create new frame based on cumulative length of fields
#
$tsumfl = $tot_sumfl;
$maxfl = 110;
$i = 0;
while ($tsumfl>0 && $i<51) {
#print "$tsumfl:$i\n";
$sumfl = 0;
$fr1 = $tl->Frame;
$fr1->pack(-anchor=>'w');
while (($sumfl+$fieldlen[$i]+length($fieldnam[
$i])) < $maxfl && $i<51) {
#print " $i:$fieldnam[$i]:$fieldlen[$i]:$row[$i]:
$sumfl\n";
$fr1->Label(-text=>$fieldnam[$i])->pack(-side=>'left',-anchor=>'w');
$fr1->Entry(-width=>$fieldlen[$i],-textvariable=>\$row[$i])->pack(-side=>'le
ft',-anchor=>'w');
$sumfl = $sumfl + $fieldlen[$i] + length($fieldnam[$i]);
$i = $i + 1;
}
$i = $i;
$tsumfl = $tsumfl - $sumfl;
}
$fr1 = $tl->Frame;
$fr1->pack(-anchor=>'w');
$fr1->Label(-text=>"insert point after")->pack(-side=>'left',-anchor=>'w');
$fr1->Entry(-width=>5,-textvariable=>\$ins_pt)->pack(-side=>'left',-anchor=>
'w');
$fr1->pack(-anchor=>'w');
#
# add polygon data
#
# first make scrollable pane
$fr2=$tl->Scrolled(Pane, -scrollbars=>'oe')->pack(-expand=>1,-fill=>'both',-
anchor=>'w');
$fr1 = $fr2->Frame;
$fr1->pack(-anchor=>'w');
$fr1->Label(-font=>'Courier -14 bold',-text=>'quad point')->pack(-side=
>'left',-anchor=>'w');
$fr1->Label(-font=>'Courier -14 bold',-text=>'cid')->pack(-side=>'left',-anc
hor=>'w');
$fr1->Label(-font=>'Courier -14 bold',-text=>'lty')->pack(-side=>'left',-anc
hor=>'w');
$fr1->Label(-font=>'Courier -14 bold',-text=>'sd ')->pack(-side=>'left',-an
chor=>'w');
$fr1->Label(-font=>'Courier -14 bold',-text=>'latitude longitude')->pack(-
side=>'left',-anchor=>'w');
# dummy data
@qn= ('576 NE') x $npp;
@pn= ('096') x $npp;
@cid= ('0001') x $npp;
@lty= ('1') x $npp;
@sd= ('S') x $npp;
@bndy=('31.3750') x $npp;
@bndx=('101.3245') x $npp;
# this for loop writes actual polygons
for ($f=0;$f<$npp+1;$f++) {
$fr1 = $fr2->Frame;
$fr1->pack(-anchor=>'w');
$fr1->Entry(-font=>'Courier -14',-width=>8,-textvariable=>\$qn[$f])->pack(-s
ide=>'left',-anchor=>'w');
$fr1->Entry(-font=>'Courier -14',-width=>5,-textvariable=>\$pn[$f])->pack(-s
ide=>'left',-anchor=>'w');
$fr1->Entry(-font=>'Courier -14',-width=>3,-textvariable=>\$cid[$f])->pack(-
side=>'left',-anchor=>'w');
$fr1->Entry(-font=>'Courier -14',-width=>3,-textvariable=>\$lty[$f])->pack(-
side=>'left',-anchor=>'w');
$fr1->Entry(-font=>'Courier -14',-width=>3,-textvariable=>\$sd[$f])->pack(-s
ide=>'left',-anchor=>'w');
$fr1->Entry(-font=>'Courier -14',-width=>10,-textvariable=>\$bndy[$f])->pack
(-side=>'left',-anchor=>'w');
$fr1->Entry(-font=>'Courier -14',-width=>10,-textvariable=>\$bndx[$f])->pack
(-side=>'left',-anchor=>'w');
}
#
# add button widget
#
$tl->Button(-activebackground=>'yellow',-text=>"PROCESS", -command=>sub {exi
t})->pack(-side=>'top');
MainLoop;
--------------020600020800000900040004--
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.