in reply to Re: Tk button appearance while its callback runs
in thread Tk button appearance while its callback runs

Well, yet another of my misconceptions (regarding the needfulness of $mw->update) has been brought out into the light of day (where, hopefully, it will wither away and die).

After some experimentation, I think I have something that does what you want. I had to combine several different things together, but that appears to the 'Tk' way. So without further ado...

#!/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

Replies are listed 'Best First'.
Thanks Re: Tk button appearance while its callback runs
by ff (Hermit) on Oct 11, 2002 at 21:11 UTC
    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