Mit
configure:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use warnings;
use strict;
use Tk;
my $mw = MainWindow->new();
my $b_yel = $mw->Button(
-command => [sub{$mw->configure(-background => '#FFFF00')}],
-text => 'Gelb'
)->pack();
my $b_mag = $mw->Button(
-command => [sub{$mw->configure(-background => '#FF00FF')}],
-text => 'Magenta'
)->pack();
$mw->configure(-background => '#FFFFFF');
MainLoop();
Nachtrag: eckige Klammern um Callbacks kann man hier auch weglassen, da keine Argumente mitgegeben werden.
Editiert von FIFO: Nachtrag
Last edited: 2011-11-16 12:50:07 +0100 (CET)
Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it? -- Brian Kernighan: "The Elements of Programming Style"