Good Morning Monks here is my question for the day. Refering to the code below once the "Add" button is pressed the data is entered into the file and the window is withdrawn and the mother window is de-iconified. If I select the "Add" button again the data entry box reappears and instead of having clear entry boxes the previous data is still shown. I've tried using : update, delete etc. What I am missing? Thanks in advance.
sub addnewcar {
$addcm = $mw->Toplevel();
$addcm->transient($mw);
$addcm->group($mw);
$addcm->resizable(0,0);
$addcm->protocol('WM_DELETE_WINDOW' => sub {
print "do nothing here\n"; #prevents destruction of $addcm
#by WM control
});
# Create the main window
$addcm->configure(-title=>'Add Car');
$addcm->geometry('285x270+0+0');
my $personInfo = $addcm->Frame()->pack(-side=>'top',-fill=>'x');
my $personLeft = $personInfo->Frame()->pack(-side=>'left',-fill=>'x'
+);
my $personRight = $personInfo->Frame()->pack(-side=>'left',-fill=>'x'
+,-padx=>20,-pady=>20);
$personLeft->Label(-text=>'Car')->pack();
$personLeft->Label(-text=>'')->pack();
$personLeft->Label(-text=>'Make')->pack();
$personLeft->Label(-text=>'Model')->pack();
$personLeft->Label(-text=>'Color')->pack();
$personLeft->Label(-text=>'Year')->pack();
$personRight->Label(-text=>'')->pack();
$personRight->Label(-text=>'')->pack();
$personRight->Entry(-width=>20,-borderwidth=>2,
-relief=>'sunken',-textvariable=>\$perInfo->{MAKE})->pack();
$personRight->Entry(-width=>20,-borderwidth=>2,
-relief=>'sunken',-textvariable=>\$perInfo->{MODEL})->pack();
$personRight->Entry(-width=>20,-borderwidth=>2,
-relief=>'sunken',-textvariable=>\$perInfo->{COLOR})->pack();
$personRight->Entry(-width=>20,-borderwidth=>2,
-relief=>'sunken',-textvariable=>\$perInfo->{YEAR})->pack();
my $saveFrame = $addcm->Frame()->pack(-side=>'top',-fill=>'x');
$saveFrame->Button(-text => 'Add Car', -command => sub { &addcar(); sl
+eep 2; $addcm->withdraw; $rm->deiconify;}
)->grid(-row, 2, -column, 0, -sticky => 'nesw');
$balloon->attach($saveFrame, -balloonmsg => "Return To Add Car");
sub addcar {
open(OUT,">>cardata.txt");
print OUT $perInfo->{MAKE} . ":";
print OUT $perInfo->{MODEL} . ":";
print OUT $perInfo->{COLOR} . ":";
print OUT $perInfo->{YEAR} . "\n";
close(OUT);
}
} # END ADD NEW CAR
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.