Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: Tk button appearance while its callback runs

by BlueBlazerRegular (Friar)
on Oct 11, 2002 at 16:36 UTC ( [id://204577]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://204577]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-24 17:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found