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

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

  • Comment on Re: Tk button appearance while its callback runs

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

      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