Raad has asked for the wisdom of the Perl Monks concerning the following question:
Tk maestroes out there, a tk database book would be a great seller. I know of a number of people, including myself, who would pay anything for a book entitled SQLite and Tk! Any volunteers:}
use strict; use Tk; use Tie::IxHash; tie %hash, "Tie::IxHash"; my $i=1; my %hash =( 1=>["Sappy", "Jewell", "2515 E Princeton", "Visalia", "CA" ], 2=>["Roomy", "Hilton", "12803 Westledge Ln", "Fifa", "Transvania"], 3=>[ "Lala", "Deena", "423 Northland Street", "St. Louis", "Misery" ], 4=>[ "LOLO", "Homy", "444 Wold City", "Foxy", "Flowerida" ], ); my @fields = qw/First_Name Last_Name Address City State /; my $mw=MainWindow->new (-title=>"Data Test"); my $rec_no=keys %hash; my $label = $mw->Label(-text=>"$array[$i]"); $label->pack; my $t=$mw->Scrolled("Text",-width=>50,-wrap=>'none')->pack(-expand=>1, +-fill=>'both'); $w=$t->Label(-text=>"$fields[0]",-relief=>'groove',-width=>20); $t->windowCreate('end',-window=>$w); $w=$t->Entry(-width=>20,-textvariable=>\$hash{$i}[0]); $t->windowCreate('end',-window=>$w); $t->insert('end',"\n"); $w=$t->Label(-text=>"$fields[1]",-relief=>'groove',-width=>20); $t->windowCreate('end',-window=>$w); $w=$t->Entry(-width=>20,-textvariable=>\$hash{$i}[1]); $t->windowCreate('end',-window=>$w); $t->insert('end',"\n"); $w=$t->Label(-text=>"$fields[2]",-relief=>'groove',-width=>20); $t->windowCreate('end',-window=>$w); $w=$t->Entry(-width=>20,-textvariable=>\$hash{$i}[2]); $t->windowCreate('end',-window=>$w); $t->insert('end',"\n"); $w=$t->Label(-text=>"$fields[3]",-relief=>'groove',-width=>20); $t->windowCreate('end',-window=>$w); $w=$t->Entry(-width=>20,-textvariable=>\$hash{$i}[3]); $t->windowCreate('end',-window=>$w); $t->insert('end',"\n"); $w=$t->Label(-text=>"$fields[4]",-relief=>'groove',-width=>20); $t->windowCreate('end',-window=>$w); $w=$t->Entry(-width=>20,-textvariable=>\$hash{$i}[4]); $t->windowCreate('end',-window=>$w); $t->insert('end',"\n"); $next =$mw->Button ( -relief=>'raised', -text=>"Next >>", -state=>'nor +mal',-command=>\&next ); $back =$mw->Button(-relief=>'raised', -text=>"<< Back", -state=>'norma +l',-command=>\&back ); &process_rows(); MainLoop; sub process_rows{ if ($i ==1){ $back->configure(-text=>"Back", -state=>'disabled',-command=>\&back); $next ->configure(-text=>"Next >>", -state=>'normal',-command=>\&next +); } elsif ($i == $rec_no){ $next->configure(-text=>"Next", -state=>'disabled',-command=>\&next); $back->configure(-text=>"Back", -state=>'normal',-command=>\&back); } else{ $next->configure(-text=>"Next", -state=>'normal',-command=>\&next); $back->configure(-text=>"Back", -state=>'normal',-command=>\&back); } for my $k(0..4){ $label->configure(-text=>"$i"); $label->pack; $w->configure(-textvariable=>\$hash{$i}[$k]); $t->configure(); $back->pack(-anchor=>'center', -side=>'left'); $next->pack(-anchor=>'center', -side=>'right'); } } sub next{ $i++ unless $i == $rec_no; &process_rows(); } sub back{ --$i unless $i == 1; &process_rows(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash of Arrays using Perl::Tk
by davidj (Priest) on Dec 01, 2004 at 03:38 UTC | |
by pg (Canon) on Dec 01, 2004 at 05:08 UTC | |
by davidj (Priest) on Dec 01, 2004 at 08:27 UTC | |
by Raad (Acolyte) on Dec 01, 2004 at 14:02 UTC | |
|
Re: Hash of Arrays using Perl::Tk
by graff (Chancellor) on Dec 01, 2004 at 05:00 UTC | |
by Raad (Acolyte) on Dec 01, 2004 at 14:22 UTC | |
by davidj (Priest) on Dec 01, 2004 at 08:33 UTC | |
by graff (Chancellor) on Dec 03, 2004 at 02:16 UTC | |
|
Re: Hash of Arrays using Perl::Tk
by si_lence (Deacon) on Dec 01, 2004 at 08:24 UTC | |
|
Re: Hash of Arrays using Perl::Tk
by zentara (Cardinal) on Dec 01, 2004 at 12:54 UTC | |
|
Re: Hash of Arrays using Perl::Tk
by zentara (Cardinal) on Dec 01, 2004 at 13:44 UTC |