Do I always have to provide Tkx's -command argument an anonymous subroutine?
Posted
by Zaid
on Stack Overflow
See other posts from Stack Overflow
or by Zaid
Published on 2010-04-12T07:22:41Z
Indexed on
2010/04/12
7:53 UTC
Read the original article
Hit count: 391
I find it a bit weird that I have to wrap defined subroutines anonymously when specifying the -command
argument for Tkx widgets.
An excerpt from a TkDocs tutorial demonstrates this:
my $cb = $frm->new_ttk__button ( -text => "Calculate",
-command => sub {calculate();} );
sub calculate {
$meters = int(0.3048*$feet*10000.0+.5)/10000.0 || '';
}
Why doesn't it work when I write -command => &calculate()
or -command => \&calculate()
?
© Stack Overflow or respective owner