use Tk; $window = MainWindow->new(-background => 'white'); $window->Button(-text => 'Red', -command => sub { colorset('red') })->pack(-side => 'bottom'); $window->Button(-text => 'Blue', -command => sub { colorset('blue') })->pack(-side => 'right'); $window->Button(-text => 'Green', -command => sub { colorset('green') })->pack(-side => 'left'); $window->Button(-text => 'Quit', -command => sub { exit() })->pack(-side => 'top'); MainLoop(); sub colorset { $color = shift(); $window->configure(-background => $color); }