sub count_up {
{
.
.
.
}
}
####
$cnt=0; $progress=0
$cnt=0; $progress=20
$cnt=0; $progress=40
$cnt=0; $progress=60
####
my $r = \$progress;
print("address of \$progress=$r\n");
####
$cnt=0; $progress=0
address of $progress=SCALAR(0x19fc970)
$cnt=0; $progress=20
address of $progress=SCALAR(0x19fe710)
$cnt=0; $progress=40
address of $progress=SCALAR(0x1cfdb0c)
$cnt=0; $progress=60
address of $progress=SCALAR(0x1d13fc4)
####
$pb->configure(
-from => 0,
-to => 20,
-variable => \$progress, ## store the reference.
);
$progress = 0;
####
$cnt=0; $progress=0
$cnt=0; $progress=0
$cnt=0; $progress=0
$cnt=0; $progress=0
####
sub variable {
my $c = shift;
my $oldvarref = $c->{'-variable'};
my $oldval = $$oldvarref if $oldvarref;
if(@_) {
my $varref = shift;
if ($oldvarref)
{
$c->traceVdelete($oldvarref);
}
$c->{'-variable'} = $varref;
$c->traceVariable($varref, 'w', sub { $c->value($_[1]) });
$$varref = $oldval;
_layoutRequest($c,2);
}
$oldval;
}
####
use strict;
use warnings;
use Tk;
use Tk::ProgressBar;
my $mw = MainWindow->new(-title=>"Bug Demo");
my $progress;
my $pb = $mw->ProgressBar(
-width => 20,
-length => 200,
-blocks => 20,
-from => 0,
-to => 20,
-variable => \$progress, ## store the reference.
)->pack();
my $button = $mw->Button(
-text => 'Press this!',
-command => \&count_up,
)->pack();
MainLoop;
sub count_up {
$progress = 0;
$mw->update;
for (1..20) {
select(undef, undef, undef, 0.01);
$progress++;
$mw->update;
}
}