I added zentara's script to mine and got this:
#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::NoteBook; my $starttime; my $raisetime; my $progressbar; my $percent_done; my $mw = MainWindow->new(); $mw->geometry("400x100"); my $book = $mw->NoteBook()->pack( -fill => 'both', -expand => 1 ); my $tab1 = $book->add( "Sheet 1", -label => "Start", -createcmd => \&getStartTi +me ); my $tab2 = $book->add( "Sheet 2", -label => "Continue", -raisecmd => \&getCurre +ntTime ); my $tab3 = $book->add( "Sheet 3", -label => "Progress", -createcmd => \&getProg +ressBar ); my $tab4 = $book->add( "Sheet 4", -label => "Command", -createcmd => \&getExecu +teCommand ); my $tab5 = $book->add( "Sheet 5", -label => "End", -state => 'disabled +' ); $tab1->Label( -textvariable => \$starttime )->pack( -expand => 1 ); $tab2->Label( -textvariable => \$raisetime )->pack( -expand => 1 ); $tab3->Button( -text => 'Quit', -command => sub { exit; } ) ->pack( -expand => 1 ); MainLoop; sub getStartTime { $starttime = "Started at " . localtime; } sub getCurrentTime { $raisetime = " Last raised at " . localtime; $book->pageconfigure( "Sheet 3", -state => 'normal' ); } sub getProgressBar { my $mw = MainWindow->new( -title => 'ProgressBar example' ); my $progress = $mw->ProgressBar( -width => 30, -from => 0, -to => 100, -blocks => 50, -colors => [ 0, 'green', 50, 'yellow', 80, 'red' ], -variable => \$percent_done )->pack( -fill => 'x' ); $mw->Button( -text => 'Go!', -command => sub { for ( my $i = 0 ; $i < 1000 ; $i++ ) { $percent_done = $i / 10; print "$i\n"; $mw->update; } } )->pack( -side => 'bottom' ); MainLoop; } sub getExecuteCommand { use Tk; use Tk::ExecuteCommand; use Tk::widgets qw/LabEntry/; use strict; my $mw = MainWindow->new; my $ec = $mw->ExecuteCommand( -command => '', -entryWidth => 50, -height => 10, -label => '', -text => 'Execute', )->pack; $ec->configure(-command => 'date; sleep 10; date'); my $button = $mw->Button(-text =>'Do_it', -background =>'hotpink', -command => sub{ $ec->execute_command }, )->pack; MainLoop; }

In reply to Re: perl/tk show script progress by Khen1950fx
in thread perl/tk show script progress by swoop

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.