"... I could only find one answer about using threads ine that node, and I didn't understand it sorry."

Perhaps a look at the Perl Threads Tutorial might help.

Here's a technique for creating image data and updating a progress bar without using threads. I've made no attempt to integrate canvasses, rectangles, etc. This is a complete working script — you should be able to run it as is.

#!/usr/bin/env perl use strict; use warnings; use Tk; use Tk::Photo; use Tk::ProgressBar; my $mw = MainWindow->new(); $mw->geometry("200x200"); my $action_F = $mw->Frame()->pack(-side => 'bottom'); my $exit_B = $action_F->Button(-text => 'Exit', -command => sub { exit + })->pack; my $image_F = $mw->Frame( )->pack(-padx => 10, -pady => 10, -expand => 1, -fill => 'both'); my $progress_F = $mw->Frame( )->pack(-padx => 10, -pady => 10, -expand => 0, -fill => 'x'); my ($image_height, $image_width) = (100, 100); my $image = $image_F->Photo(-height => $image_height, -width => $image +_width); $image_F->Label(-image => $image)->pack; my $pc_image_drawn = 0; my $progress_PB = $progress_F->ProgressBar(-variable => \$pc_image_dra +wn )->pack(-fill => 'x'); for my $height (0 .. $image_height - 1) { for my $width (0 .. $image_width - 1) { $image->put('#ffcc33', -to => $width, $height); $image->update; # called in inner loop for slow demonstration +display } $pc_image_drawn = (($height + 1) / ($image_height)) * 100; } MainLoop;

-- Ken


In reply to Re^3: Threading Problems by kcott
in thread Threading Problems by jerre_111

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.