john.tm has asked for the wisdom of the Perl Monks concerning the following question:
use warnings; use strict; use Tk; use POSIX 'strftime'; use Tk::ErrorDialog; my $DATE = strftime(" report.pl for %d %b %Y " , localtime()); my $title = strftime(" Processing daily Failures for %d %B %Y" , local +time()); my $mw = MainWindow->new; my $filenameA = "c:\\Temp\\perl.txt"; $mw->geometry("720x500"); $mw->title(" report "); my $main_frame = $mw->Frame()->pack(-side => 'top', -fill => 'x'); my $left_frame = $main_frame->Frame(-background => "snow2")->pack(-sid +e => 'left', -fill => 'y'); my $right_frame = $main_frame->Scrolled("Text", -scrollbars => 'se',-b +ackground => "black",-foreground => "green",-height => '44')->pack(-e +xpand => 1, -fill => 'both'); my $failures_button = $left_frame->Button(-text => "$DATE ", -command => [\&runscript])->pack; my $guide = $left_frame->Button(-text => " Clear Screen + ", -command => [\&clear_screen])->pack; my $Close_button = $left_frame->Button(-text => ' Exit + ', -command => [$mw => 'destroy'])->pack; my $Help_button = $left_frame->Button(-text => " Help Guide + ", -command => \&help_file)->pack(-side = +> "bottom"); my $About = $left_frame->Button(-text => ' About + ', -command => \&About_file)->pack(-side => "bottom"); + MainLoop; sub runscript { open (daily_fail, '-|', 'report.pl &') or die "unable to start dail +y_failues.pl"; my $first_line = " please wait......\n $title........\n"; $right_frame->delete("1.0", 'end'); $right_frame->insert( 'end', $first_line ); my $daily_fail_line; while (defined ($daily_fail_line =<daily_fail>) ) { $right_frame->insert( 'end', $daily_fail_line ); $right_frame->update(); $right_frame->see('end'); } } sub clear_screen { $right_frame->delete('1.0','end'); } sub About_file { $right_frame->delete("1.0", 'end'); open (FH, "$filenameA") or die "unable to open c:\\Temp\\perl.txt"; while (<FH>) { $right_frame->insert("end", $_); } close (FH); } sub help_file { system("tk.pl") or die "unable to start c:\\tk.pl"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Tk stderr to show in the Tk gui text widget
by kevbot (Vicar) on Jul 06, 2014 at 08:30 UTC | |
|
Re: Perl Tk stderr to show in the Tk gui text widget
by Anonymous Monk on Jul 06, 2014 at 07:03 UTC | |
|
Re: Perl Tk stderr to show in the Tk gui text widget
by zentara (Cardinal) on Jul 06, 2014 at 13:43 UTC |