...here is an example for you to check out
... the problem is how do you detect the end of playback... is some signal emitted? .... i leave the state logic broken, for you to figure out :-)
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
my $mw = Tk::MainWindow->new;
my $button = $mw->Button->pack(-side =>'left');
my $button1 = $mw->Button(-text => 'Go ',
-state => 'normal')->pack( -side =>'left');
my $x = $mw->Pixmap(
-data => qq(/* XPM */
static char * x_xpm[] = {
"24 24 2 1",
" c None",
". c #000000",
" ",
" ",
" ",
" ",
" ",
" ",
" ... ... ",
" .. .. ",
" ... .. ",
" .. ... ",
" .... ",
" ... ",
" ... ",
" .... ",
" .. .. ",
" ... .. ",
" .. ... ",
" .. .. ",
" ... ... ",
" ",
" ",
" ",
" ",
" "};
));
my $o = $mw->Pixmap(
-data => qq(/* XPM */
static char * o_xpm[] = {
"24 24 2 1",
" c None",
". c #000000",
" ",
" ",
" ",
" ",
" ",
" ",
" ...... ",
" ........ ",
" ... ... ",
" .. .. ",
" .. .. ",
" .. .. ",
" .. .. ",
" .. .. ",
" .. .. ",
" .. .. ",
" ... ... ",
" ........ ",
" ...... ",
" ",
" ",
" ",
" ",
" "};
));
my @toggle = ($x, $o);
my @toggle1 = ('Go ','Whoa');
$button->configure(
-image => $x,
-command => sub {
@toggle = @toggle[1, 0];
@toggle1 = @toggle1[1, 0];
$button->configure(-image => $toggle[0]);
if ( $toggle1[0] eq 'Go '){
$button1->configure( -text => $toggle1[0],
-state => 'normal',
);
}else{
$button1->configure( -text => $toggle1[1],
-state => 'disabled',
);
}
}
);
Tk->MainLoop;
|