#!/usr/bin/perl
use Tk;
use strict;
use Tk::ExecuteCommand;
my $mw = MainWindow->new;
my $ec = $mw->ExecuteCommand(
-command => '',
-entryWidth => 50,
-height => 10,
-label => '',
-text => 'Execute',
)->pack;
$ec->configure(-command => 'ls -la');
$ec->execute_command;
$ec->bell;
$ec->update;
MainLoop;
####
#!/usr/bin/perl
use Tk;
use strict;
use constant BUTTON_WIDTH => 20;
my $mw = new MainWindow(title => "demo");
my $button = $mw->Button(text => "color",
width => BUTTON_WIDTH)
->pack;
$mw->Button(text => "red",
width => BUTTON_WIDTH,
command => sub {change_color($button, "red")})
->pack;
$mw->Button(text => "green",
width => BUTTON_WIDTH,
command => sub {change_color($button, "green")})
->pack;
MainLoop;
sub change_color {
my ($widget, $color) = @_;
$widget->configure(background => $color);
}
####
#!/usr/bin/perl
use Tk;
use strict;
my $mw = MainWindow->new;
my @color = qw/red lightgray/;
my $bits = pack("b8"x8,
"...11...",
"..1111..",
".111111.",
"11111111",
"11111111",
".111111.",
"..1111..",
"...11...",);
$mw->DefineBitmap('indicator' => 8,8, $bits);
my $label = $mw->Label(-bitmap=>'indicator', -fg=>'red')->pack;
$mw->repeat(500,sub{$label->configure(
-fg=>$color[0]);
@color=reverse(@color);
});
MainLoop;