£okì has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use Tk 800.00; use Mysql; require Tk::Frame; require Tk::TextUndo; require Tk::Text; require Tk::Scrollbar; require Tk::Menu; require Tk::Menubutton; require Tk::Adjuster; require Tk::DialogBox; # Main Window my $mw = new MainWindow; $mw->geometry('800x600'); # Frames Setup my $lf = $mw->Frame; # Left Frame; my $rf = $mw->Frame; # Right Frame; # Menu Bar Setup my $mb = $mw->Menu(-menuitems => &menubar_menuitems() ); $mw->configure(-menu => $mb); $mw->title("INSCO Inventory Control"); my($label_input) = $lf->Label( -text=>'Serial Number: ', ); my $tf_serial=$lf->Entry(-width=>30); my ($label_space) = $lf->Label( -text=>'', ); my $returned = ""; my $button_submit = $mw->Button(-text => 'Search', -command => $returned = sub{return(get_data($tf_serial))} ); my($label_po) = $rf->Label( -text=>'PO: ', ); my $tf_po=$rf->Entry(-width=>30); my($label_client) = $rf->Label( -text=>'Client: ', ); my $tf_client=$rf->Label(-width=>30, -text=>$returned); my($label_contact) = $rf->Label( -text=>'Contact: ', ); my $tf_contact=$rf->Entry(-width=>30); my($label_phone) = $rf->Label( -text=>'Contact Phone Number: ', ); my $tf_phone=$rf->Entry(-width=>30); my($label_email) = $rf->Label( -text=>'Contact Email Address: ', ); my $tf_email=$rf->Entry(-width=>30); my($label_address) = $rf->Label( -text=>'Contact Street Address: ', ); my $tf_address=$rf->Entry(-width=>'75'); my $tf_city=$rf->Entry(-width=>30); my $tf_state=$rf->Entry(-width=>30); my $tf_zipcode=$rf->Entry(-width=>30); my($label_id) = $rf->Label( -text=>'Client\'s Product ID: ', ); my $tf_id=$rf->Entry(-width=>30); my($label_model) = $rf->Label( -text=>'Product Model: ', ); my ($tf_model)=$rf->Entry(-width=>30); # Pack everything $lf->pack(qw/-side left -fill y/); $rf->pack(qw/-side right -fill y/); $label_input->pack(qw/-side top/); $tf_serial ->pack(qw/-side top/); $label_space ->pack(qw/-side top/); $button_submit ->pack(qw/-side top/); $label_po->pack(qw//); $tf_po->pack(qw//); $label_client->pack(qw//); $tf_client->pack(qw//); $label_contact->pack(qw//); $tf_contact->pack(qw//); $label_phone->pack(qw//); $tf_phone->pack(qw//); $label_email->pack(qw//); $tf_email->pack(qw//); $label_address->pack(qw//); $tf_address->pack(qw//); $tf_city->pack(qw//); $tf_state->pack(qw//); $tf_zipcode->pack(qw//); $label_id->pack(qw//); $tf_id->pack(qw//); $label_model->pack(qw//); $tf_model->pack(qw//); # Start the main event loop MainLoop; sub get_data { my ($widget) = @_; my $entered = $widget -> get(); my $dbh = Mysql->connect("localhost", "insco_inventory", "INSCO", +"hernagra") or die("Could Not Connect To Server"); my $query = qq~SELECT * FROM inventory WHERE serial='$entered'~; my $sth = $dbh->query($query); my @arr = $sth->fetchrow; return($arr[2]); }
Edit by tye, add READMORE
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk Field Changes
by graff (Chancellor) on Mar 20, 2003 at 04:45 UTC | |
|
Re: Tk Field Changes
by jasonk (Parson) on Mar 19, 2003 at 21:12 UTC |