-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
See this question on PerlMonks.
To reproduce:
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Tk::ItemStyle;
use Tk::TList;
my $mw = Tk::MainWindow->new();
my $tl = $mw->TList->pack;
my %TkStyle;
my %count;
for my $color (qw( Black Red Green Blue )) {
$TkStyle{$color} = $mw->ItemStyle('text',
-stylename => $color, # <- comment this line out
-foreground => $color,
-background => 'Wheat',
-selectforeground => 'LightSeaGreen');
$tl->insert('end', -itemtype => 'text',
-text => $color,
-style => $TkStyle{$color});
++$count{ $TkStyle{$color} };
}
for my $colour (keys %TkStyle ) {
my $style = $TkStyle{$colour};
printf("%10s has count %d (style=$style)\n", $colour, $count{$style});
}
MainLoop();
Sometimes needs to run several times to misbehave. Comment the indicated line out to get the correct behaviour.
Metadata
Metadata
Assignees
Labels
No labels