Hello...I was creating a small Gtk app with perl and ran into what I think is a bug in gtk-perl. Or am I just doing this wrong?. I was looping through an array to create a bunch of buttons and ran into weird problems using signal_connect. I created a test case that creates six buttons to show this. I'm using Fedora linux 22 on intel with all updates. I also tested with both Gtk2 and Gtk3.resulting output:$ ./test.plget_label for button[0] is: fiveget_label for button[1] is: 1get_label for button[2] is: 2get_label for button[three] is: fiveget_label for button[four] is: fiveget_label for button[five] is: fivecode:$ cat test.pl#!/usr/bin/perluse Gtk2 -init;my $window = Gtk2::Window->new ("toplevel");my $layout = Gtk2::Layout->new(undef,undef);$window->add ($layout);my $vbox = Gtk2::VBox->new();$layout->add($vbox);my @button;$button[0]=Gtk2::Button->new("0");$vbox->add($button[0]);$button[0]->signal_connect (clicked => sub {# Should output 0 , but does notprint "get_label for button[0] is: ".$button[0]->get_label." \n";});$button[1]=Gtk2::Button->new("1");$vbox->add($button[1]);$button[1]->signal_connect (clicked => sub {# Should output 1print "get_label for button[1] is: ".$button[1]->get_label." \n";});$button[2]=Gtk2::Button->new("2");$vbox->add($button[2]);$button[2]->signal_connect (clicked => sub {# Should output 2print "get_label for button[2] is: ".$button[2]->get_label." \n";});$button["three"]=Gtk2::Button->new("three");$vbox->add($button["three"]);$button["three"]->signal_connect (clicked => sub {# Should output three , but does notprint "get_label for button[three] is: ".$button["three"]->get_label." \n";});# No quotes$button[four]=Gtk2::Button->new(four);$vbox->add($button[four]);$button[four]->signal_connect (clicked => sub {# Should output four , but does notprint "get_label for button[four] is: ".$button[four]->get_label." \n";});$button["five"]=Gtk2::Button->new("five");$vbox->add($button["five"]);$button["five"]->signal_connect (clicked => sub {# Should output fiveprint "get_label for button[five] is: ".$button["five"]->get_label." \n";});$window->show_all;Gtk2->main;exit 0;--Christopher McCrory
To the optimist, the glass is half full.
To the pessimist, the glass is half empty.
To the engineer, the glass is twice as big as it needs to be.
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list