#!/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_drawn )->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;