Thread Tk: change background color of mainwindow (7 answers)
Opened by a_abels at 2011-11-15 15:17

FIFO
 2011-11-15 22:05
#154222 #154222
User since
2005-06-01
469 articles
BenutzerIn

user image
Mit configure:

Code (perl): (dl )
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(); # oder new(-background => '#FFFFFF')
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"

View full thread Tk: change background color of mainwindow