Without code, I cannot speak to your recursion problems, but below is code for a progress bar I created for another application. The progress bar is in another window, but could be adapted to you main canvas. Here is the main constructor sub:

# shows progress of classification sub progress_ui { my($top_root) = @_; $progress_main->destroy if Exists($progress_main); $progress_main = $top_root->Toplevel; my($root) = $progress_main->Frame()->pack( -fill=>'both', -expand=>1 ); $progress_main->title('SpikeSort Progress'); $progress_main->iconname('SpikeSortProgress'); # widget creation my($label_2) = $root->Label ( -text => 'Percentage of trace classified:', ); # this is global $progress_canvas = $root->Canvas ( -height => '0', -highlightthickness => '0', -width => '0', ); my($label_1) = $root->Label ( -textvariable => \$spikes_found, ); # Geometry management $label_2->grid( -in => $root, -column => '1', -row => '1' ); $progress_canvas->grid( -in => $root, -column => '1', -row => '2', -sticky => 'nesw' ); $label_1->grid( -in => $root, -column => '1', -row => '3' ); # Resize behavior management # container $root (rows) $root->gridRowconfigure(1, -weight => 0, -minsize => 30); $root->gridRowconfigure(2, -weight => 0, -minsize => 80); $root->gridRowconfigure(3, -weight => 0, -minsize => 30); # container $root (columns) $root->gridColumnconfigure(1, -weight => 0, -minsize => 420); # additional interface code # draw the thermometer of progress.. $progress_canvas->create( 'line', '25', '40', '395', '40', -width => '40', -fill => 'black', -cap => 'butt', ); }

The bar is just a thick line and to update the progress bar, just draw a line a little longer each time:

... elsif ( $added_text =~ /^sample index: (\d+)/ ) { $progress_width = 25 + 370 * $1 / $total_samples; $progress_canvas->create( 'line', '25', '40', $progress_width, '4 +0', -width => '40', -fill => 'blue', -cap => 'butt', ) if $progress_canvas; } ...

IIRC, the process of creating the line updates the canvas directly.

-Mark


In reply to Re: Progress bar troubles by kvale
in thread Progress bar troubles by Anonymous Monk

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.