Hi Pat,
Hmm, this is not panning out. Within the callback, running the Busy method against the widget that invoked the callback achieves the cursor change as noted above, but I'm still not able to change colors, text, etc. even with the 'update' calls.
However, you have alerted me to the fact that I was not controlling the cursor appearance either. Silly me, I thought that 'watch' was just cross-referenced incorrectly to an hourglass and didn't test using a different cursor style. Now I see that
-cursor => 'watch'
was doing nothing for me.
Thanks,
Brig | [reply] [Watch: Dir/Any] |
#!/opt/local/bin/perl -w
use strict;
use warnings;
use Tk;
my $button_label = 'Push me';
my $mw = MainWindow->new;
$mw->geometry("300x200+20+20");
$mw->title( "Tk Testing" );
my $button;
$button = $mw->Button(
-textvariable => \$button_label,
-underline => 0,
-foreground => 'blue',
-command => sub {
my $saved_label = $button_label;
$button_label = 'Ouch!';
$button->configure(
-relief => 'flat',
-activeforeground => 'red',
-activebackground => 'green',
);
$button->Busy(-recurse => 1 );
sleep( 10 );
$button_label = $saved_label;
$button->configure(
-relief => 'raised',
-foreground => 'blue',
);
$button->Unbusy;
},
)->pack(-side => 'top',
-anchor => 'center',
-fill => 'none',
-expand => 0,
-padx => 5,
-pady => 5,
);
MainLoop;
exit 0;
__END__
Hope this is useful. Even if it isn't, I've learned something, so it wasn't a complete waste. :)
Pat | [reply] [Watch: Dir/Any] [d/l] [select] |
Dear Monks,
Thanks for your assistance. My button works as desired now: while my button's callback does its thing, it:
has a different color
has different text
has relief of 'sunken'
cursor changes to hourglass.
Surely my user will believe the program is doing SOMETHING while these things are in effect.
Brig
| [reply] [Watch: Dir/Any] |