A combination of $Widget->update; and $framename->see("end"); did it. Im still open to suggestions though if anyone sees a problem with my current solution.

Just for the sake of discussion........

The problem which you present and the solution which you chose, have been talked about numerous times in different Tk threads...usually named something like "updating my Tk window".

Without seeing your code, but from your description, it sounds like the solution you have selected, is "not finely grained in realtime". It sounds like you upload a file, and when it's done, report it is done with a count of total_done and total_max. Thats usually good enough, but what if the files are very big, and take many minutes between updates?

In those cases you need to find an "upload subroutine" which triggers a callback for every 10k transfered. Now wget, curl, and lwp all have methods for downloading with this callback. If you search around through the snippets section, you should find examples with Tk.

Here is the basic lwp code for doing it. I'm just showing the lwp code, but you could see how to it could be incorporated into your Tk code to show a progessbar. Like I said, it makes a difference when your files are big, and bandwidth is low.

Check out tk-http-file-upload-w-progress

#!/usr/bin/perl -w #from lwpcook use LWP::UserAgent; $ua = LWP::UserAgent->new; $URL = 'http://zentara.net/zentara1.avi'; $filename = substr( $URL, rindex( $URL, "/" ) + 1 ); #print "$filename\n"; open( IN, ">$filename" ) or die $!; my $expected_length; my $bytes_received = 0; my $res = $ua->request(HTTP::Request->new(GET => $URL), sub { my ( $chunk, $res ) = @_; $bytes_received += length($chunk); unless ( defined $expected_length ) { $expected_length = $res->content_length || 0; } if ($expected_length) { printf STDERR "%d%% - ", 100 * $bytes_received / $expected +_length; } print STDERR "$bytes_received bytes received\n"; # XXX Should really do something with the chunk itself print IN $chunk; } ); print $res->status_line, "\n"; close IN; exit;

I'm not really a human, but I play one on earth. flash japh

In reply to Re: Tk and realtime logging. by zentara
in thread Tk and realtime logging. by injunjoel

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.