Re: I guess this is a newbie type question.



Brian Avis wrote:

I have a button like so.

$button = new Gtk::Button("Test");
$button->signal_connect("clicked", \&print_test($begin_pay_period, 
$YEAR, $days_in_year));
$button->show();

Try this:

  $button->signal_connect("clicked", \&print_test, $begin_pay_period, $YEAR, $days_in_year);

The way you wrote it, the print_test subroutine is called immediately, 
because you pass parameters to it (this is the old perl4 style 
subroutine call). A reference to the result of the subroutine call will
be passed to signal_connect, which is not what you want.

The code above passes the subroutine ref and your parameters seperately
as parameters to the signal_connect method. Then Gtk will give the 
parameters to your subroutine, when the signal handler is called.

Regards,

Joern

-- 
Joern Reder - joern netcologne de
supporting:   http://www.zyn.de/
unbelievable: http://www.netcologne.de/~nc-joernre/
CPAN:         http://www.perl.com/CPAN/modules/by-authors/id/J/JR/JRED



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]