in reply to Dynamically altering Tk buttons
... 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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Dynamically altering Tk buttons
by Llew_Llaw_Gyffes (Scribe) on Jan 04, 2010 at 16:31 UTC | |
by zentara (Cardinal) on Jan 04, 2010 at 17:25 UTC | |
by Llew_Llaw_Gyffes (Scribe) on Jan 04, 2010 at 19:27 UTC | |
by zentara (Cardinal) on Jan 05, 2010 at 12:02 UTC | |
by Llew_Llaw_Gyffes (Scribe) on Jan 05, 2010 at 19:52 UTC | |
|