I'm fairly new to Tk as I have now given up on Win32::GUI. My question about it is I have Entry fields which start blank. However, When I click a button, I want them to be filled with information based off another field.

I am to the point where I have all of the data ready but I can't figure out how to update the Entry fields. . Anyone know how?

below is my code, I am sorry about how long it is. I didn't think I'd get stuck this far in. I have deleted the menu subrouties to make this a little shorter for everyone. (they work don't worry about them.)

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


In reply to Tk Field Changes by £okì

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.