Does that explain it?
Yes, it makes sense now, after playing with this. You say refreshed, I say reset/reinitialized.
#!/usr/bin/perl --
use strict; use warnings;
use Tk;
my %in = (
a => 4, # HEAVY
b => 4,
c => 4,
d => 24,
e => 24,
f => 24,
g => 1000,
h => 150,
i => 150,
j => 150,
k => 600, # hot air baloon
);
my @ev11 = map {[$_, $in{$_}, 0, $in{$_}, undef ]} sort keys %in;
my $mw = tkinit;
my $fr = $mw->Frame( -background => 'red', )->pack;#( qw/ -expand x -f
+ill x -anchor n -side top / );
$fr->Label( -text => 'NUMHITS:')->grid( qw/ -stick ew -row 1 -column 1
+ /);
$fr->Label( -text => 'letter(interval):')->grid( qw/ -stick ew -row 2
+-column 1 /);
$fr->Label( -text => 'time remaining:')->grid( qw/ -stick ew -row 3 -c
+olumn 1 /);
my %butt;
{
#~ $one->[0] letter
#~ $one->[1] interval
#~ $one->[2] number hits
#~ $one->[3] time remaining
#~ $one->[4] button
use constant INTERVAL => 1;
use constant NUMHITS => 2;
use constant TIMEREM => 3;
use constant BUTTON => 4;
my $col = 2;
for my $one ( @ev11 ){
$fr->Label(
-relief => 'groove',
-text => $one->[0] . ' (' . $one->[1] . ')',
)->grid(
qw/ -sticky ew -row 2 /,
-column => $col
);
$fr->Label(
-relief => 'groove',
-textvariable => \$one->[NUMHITS]
)->grid(
qw/ -sticky ew -row 1 /,
-column => $col
);
$one->[BUTTON] = $fr->Button(
-command => \&Fooo,
-textvariable => \$one->[TIMEREM],
)->grid(
qw/ -sticky ew -row 3 /,
-column => $col
);
$col++;
$butt{ $one->[BUTTON] } = $one;
}
}
my $tx = $mw->ROText->pack(qw/ -expand 1 -fill both -anchor n -side to
+p / );
MainLoop;
sub Fooo {
my $b = $Tk::event->W;
$tx->insert(
'end',
sprintf '%s(%d/%d), ',
$butt{ $b }->[0] ,
$butt{ $b }->[NUMHITS] ,
$butt{ $b }->[TIMEREM],
);
for my $one ( @ev11 ){
$one->[TIMEREM]--;
$one->[BUTTON]->configure( qw/ -state normal /);
}
$butt{ $b }->[NUMHITS]++;
$butt{ $b }->[TIMEREM] = $butt{ $b }->[INTERVAL];
$b->configure( qw/ -state disabled /) ;
}
__END__
a(0/4), b(0/3), c(0/2), a(1/2), b(1/2), c(1/2), d(0/18), a(2/1), b(2/1), c(2/1), e(0/14), a(3/1), b(3/1), c(3/1), f(0/10), a(4/1), b(4/1), c(4/1),
Looks like you could have four 4-second repeaters max without dropping one ( or five 4 second repeaters and nothing else). | [reply] [d/l] |
Your code is going to take me a few minutes to digest :)
| [reply] |
digestion not required, run it, and start clicking buttons, don't let a button go negative
After about a minute you'll start to see some patterns (maybe even a formula)
| [reply] |