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

In reply to Tk Clear Text by PilotinControl

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.