I am beginner in perl Tk Sometime ago I asked even a book for perl Tk but you people suggested me to go through online documentation rather than a book coz documentation are more up2date in compare of a book so here is what I made
use Tk; use strict; my $mw = MainWindow->new; $mw->geometry("200x300"); $mw->title("MAIN WINDOW"); my $lname1; my $button_frame1 = $mw->Frame()->pack(-side => "top"); $button_frame1->Button(-text => "GI EXTRACTOR", -command => \&window1) +->pack(); sub window1 { my $mw = MainWindow->new; $mw->geometry("700x700"); $mw->title("GI EXTRACTOR WINDOW"); my $button_frame1 = $mw->Frame()->pack(-side => "top"); $button_frame1->Button(-text => "Browse File", -command => \&updat +e_output1)->pack(-side => "top"); my $bf1 = $mw->Frame()->pack(-side => "top"); $bf1->Label(-text => "You Have Selected The Following File")->pack +(-side => "left"); $bf1->Entry(-bg=>'red',-textvariable => \$lname1)->pack(-side => " +left"); my $b_f1 = $mw->Frame()->pack(-side => "top"); $b_f1->Button(-text => "Ok", -command => \&u_o1)->pack(-side => "b +ottom"); my $output_frame1 = $mw->Frame()->pack(-side => "bottom"); my $output_scroll1 = $output_frame1->Scrollbar(); my $output_text1 = $output_frame1->Text(-yscrollcommand => ['set', + $output_scroll1]); $output_scroll1->configure(-command => ['yview', $output_text1]); $output_scroll1->pack(-side => "right", -expand => "no", -fill => +"y"); $output_text1->pack(); sub update_output1 { my $button_frame1 = $mw->getOpenFile(); $lname1=$button_frame1; } sub u_o1 { my $output1; open(FH,"<$lname1"); while(my $_=<FH> ) { if($_=~/^>gi/) { my@arr=split(/\|/,$_); $output1=$arr[0].$arr[1]; } } close(FH); $output_text1->delete('0.0', 'end'); $output_text1->insert("end", $output1); } } MainLoop;

This is a simple Tk program which opens a Main Window having a button called"GI Extractor" After clicking on it gives a new window" GI Extractor WINDOW" having total 5 widget

1.Browse file(which call getOpenFile()); 2.label (shows hardcoded text); 3.ENTRY(which show address of selected file); 4.ok button (which call mechanism of this program); 5.scrollbox(which shows ouput);

Now when I click on GI Extractorbutton in "Main Window", It works like a charm

But when once I close "GI EXTRACTOR WINDOW"and Reopen it using same button It neither Deletes previous entry nor takes new Entry

Instead of it gives a very long error in Command line

Hoping for a good reply with some example code coz I searching for this problem since last 5 hour please help


In reply to widget box problem in tk by prince26121991

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.