Hi,

I am writing a small perl script to process files, so for each file I should get some kind of input from user to further processing. So I have written a foreach loop and processing each file, to get the input from user i have written perl tk code. but after taking the input from user, its not processing further. I am doing doing destroy in okbutton.

sub okbutton(){ $repo_path = $path_entry ; print($repo_path ); my $mbox_error=''; if ( not $repo_path ){ $mbox_error =$mw->messageBox(-icon=>'error', -title=>'Error on Repository Path', -message=>"Error: Repository path s +hould not be empty." ); return (""); } if (! -d "$repo_path"){ $mbox_error =$mw->messageBox(-icon=>'error', -title=>'Error on Repository Path', -message=>"Error: Repository path i +s not a valid path." ); return (""); } $mw->destroy if Tk::Exists($mw); } foreach my $each_file (@files){ ..... ..... { $mw = MainWindow->new; $mw->geometry("400x120"); $mw->title("CI Generation"); #-----------------Frames-----------------------# my $main_frame = $mw->Frame()->pack( -side => 'top', - fill => 'x +' ); my $top_frame = $mw->Frame( -background => 'light green' )->pack( -side => 'to +p', -fill => 'x' ); my $left_frame = $mw->Frame( -background => 'white' )->pack( -side => 'top', -f +ill => 'x' ); $top_frame->Label( -text => "Copy generated *.[ch] files to host repository", #-background => 'cyan' ) ->pack( -side => 'top' ); $left_frame->Label( -text => "Enter host repository path:", -background => 'yellow' )->pack( -side => 'top', -fill => 'x' ); my $entry = $left_frame->Entry( -textvariable => \$path_entry, -width => 50)->pack( -side => 'top', -fill => 'x' ); my $buttons = $left_frame->Frame()->pack(-side => 'bottom', -fill=>'both', - +expand=> 0); my $executeButton= $buttons->Button( -text => "Continue", -command => \&okbutton, -width => 20, -height => 2, -underline => 11 )->pack(-side => "left"); my $exitButton = $buttons->Button( -text => "Cancel", -command => sub { exit 1; }, -width => 20, -height => 2, -underline => 11 )->pack(-side => "right"); MainLoop; } }

All is well. I learn by answering your questions...

In reply to perl tk get user input by vinoth.ree

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.