Subject: | Error with -variable when list provided as hash reference |
Date: | Thu, 4 May 2017 11:25:20 +0200 |
To: | bug-Tk-CheckbuttonGroup [...] rt.cpan.org |
From: | Andreas Pawlak <andreas.pawlak [...] tu-dresden.de> |
Dear Jannino,
I can across a possible bug for the CheckbuttonGroup. When providing a
hash-reference as -list and a list of values for all keys, the group
items are not activated. If I instead pass a list of the keys itself,
then it works. However, when activating or deactivating the items in the
group, the values for each key are provided into the -variable list (as
expected).
Expected correct code that did not work:
my %item;
$item{$_->{name}} = $_->{id} foreach @$items;
my @item_select = map $_->{id}, @$items; # provide the values
$wind->CheckbuttonGroup(-orientation => 'vertical', -list => \%item,
-variable => \@item_select, -command => sub { print
Data::Dumper::Dumper(\@item_select); })->pack;
Code that did work (but not as expected)
my %item;
$item{$_->{name}} = $_->{id} foreach @$items;
my @item_select = map $_->{name}, @$items; # provide the keys
$wind->CheckbuttonGroup(-orientation => 'vertical', -list => \%item,
-variable => \@item_select, -command => sub { print
Data::Dumper::Dumper(\@item_select); })->pack;
This issue can easily be resolved by changing the line #81 to
Checkbutton => $val->{$item},
instead of the original
Checkbutton => $item,
Thank you in advance for looking into this issue.
Best regards,
Andreas Pawlak
--
Dr.-Ing. Andreas Pawlak
Technische Universität Dresden
Institute of Circuits and Systems (IEE)
Chair for Electron Devices and Integrated Circuits
01062 DRESDEN Phone: +49 351 463 32805
GERMANY Fax: +49 351 463 37260
E-Mail: andreas.pawlak@tu-dresden.de
Message body not shown because it is not plain text.