... Reopen it using same button It neither Deletes previous entry nor takes new Entry ...

Yup, typical coping with scoping issue ( life cycle of variables ), see lots and lots links in Re^2: Perl Gtk2 - ->destroy() is Not Causing the Script to Exit

links like Re^2: Border-less main window (Alt+F4 Ctrl+C , Re: Perk Tk - how to send a value from a subroutine back to the main program using Button (without MainLoop), Re: Perl tk FindNext in a text widget, Confused by variable scope in Tk::Wizard

Then write Tk callbacks all lexically scoped and not-memory leaking with no nested subs ever :) avoid nested subs and closures because nested named subs because they're closures

Also, meaningful variable/function names are good :)

Here is your program slightly fixed up (so it doesn't error message), could use more fixing (for readability/understandability...) ... if you don't understand the changes I made start with a pencil & paper description of your program:)

#!/usr/bin/perl -- #~ #~ 2014-05-11-19:59:34 #~ ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr +-ce -nibc -i=4 -pt=0 "-nsak=*" #!/usr/bin/perl -- use Tk; use strict; Main( @ARGV ); exit( 0 ); sub Main { my $mw = MainWindow->new; $mw->geometry( "200x300" ); $mw->title( "MAIN WINDOW" ); my $button_frame1 = $mw->Frame()->pack( -side => "top" ); $button_frame1->Button( -text => "GI EXTRACTOR", -command => \&win +dow1 ) ->pack(); MainLoop; } ## end sub Main sub window1 { my $mw = MainWindow->new; $mw->geometry( "700x700" ); $mw->title( "GI EXTRACTOR WINDOW" ); my $button_frame1 = $mw->Frame()->pack( -side => "top" ); my $lname1; ## eew var name:) #~ $button_frame1->Button(-text => "Browse File", -command => \&up +date_output1)->pack(-side => "top"); $button_frame1->Button( -text => "Browse File", -command => [ \&update_output1, $mw, \$lname1 ] )->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 => + "bottom"); my $output_frame1 = $mw->Frame()->pack( -side => "bottom" ); my $output_scroll1 = $output_frame1->Scrollbar(); my $output_text1 = $output_frame1->Text( -yscrollcommand => [ 'set', $output_scroll +1 ] ); $output_scroll1->configure( -command => [ 'yview', $output_text1 ] + ); $output_scroll1->pack( -side => "right", -expand => "no", -fill => + "y" ); $output_text1->pack(); $b_f1->Button( -text => "Ok", -command => [ \&u_o1, $output_text1, \$lname1 ] )->pack( -side => "bottom" ); } ## end sub window1 sub update_output1 { #~ my $button_frame1 = $mw->getOpenFile(); #~ my $button_frame1 = shift( @_ )->getOpenFile(); my( $mmmwww, $lnameref ) = @_; my $button_frame1 = $mmmwww->getOpenFile(); $$lnameref = $button_frame1; } sub u_o1 { my( $output_text1, $lnameref ) = @_; my $output1; use autodie; #~ open( FH, "<$lname1" ); open my( $fh ), '<', $$lnameref; 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 ); } ## end sub u_o1

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

I'd be very interested to learn what keywords you searched for


In reply to Re: widget box problem in tk by Anonymous Monk
in thread 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.