PilotinControl has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk Clear Text
by hdb (Monsignor) on Aug 26, 2013 at 13:06 UTC | |
by PilotinControl (Pilgrim) on Aug 26, 2013 at 13:22 UTC | |
|
Re: Tk Clear Text
by choroba (Cardinal) on Aug 26, 2013 at 13:01 UTC |