1 2 3 4 5 6 7 8 9 10 11 12 13
#!/usr/local/bin/perl use strict; use warnings; use Tk; my $mw = tkinit(); my $txt_var; my $spin = $mw->Spinbox(-from => 0, -to => 100, -textvariable => \$txt_var)->pack(-side => 'left'); $spin->bind('<Return>', sub {print shift . "\n" . $txt_var}); MainLoop;
1
2
3
4
my $spinbox = $mw->Spinbox(-from => 1980, -to => 2037, -command => sub {
print $anzeige_jahr_w->get()})->pack();
$spinbox->bind('<Return>',sub { ... Command von Spinbox ausführen ohne die Sub doppelt anzulegen ...});
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/usr/local/bin/perl use strict; use warnings; use Tk; my $mw = tkinit(); my $txt_var; my $spin = $mw->Spinbox( -from => 0, -to => 100, -textvariable => \$txt_var, -command => sub {print $txt_var . "\n"} ) ->pack(-side => 'left'); my $cmd = $spin->cget('-command'); $spin->bind('<Return>', $cmd); MainLoop;
$spinbox->bind('<Return>', $spinbox->cget(-command));
1 2 3
sub spin_cmd {print $anzeige_jahr_w->get()}; my $spinbox = $mw->Spinbox(-from => 1980, -to => 2037, -command => \&spin_cmd)->pack(); $spinbox->bind('<Return>', \&spin_cmd);
2014-05-23T15:09:05 KeanOder täusche ich mich?