Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl/Tk - execute multiple subs by one button ?

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Joined
Feb 6, 2002
Messages
1,851
Location
IL
Hi,

Is it possible to activate 2 subs+one extra command just by one button ?

Thanks

Long live king Moshiach !
 
Code:
-command => sub {
   &red();
   &blue();
   print "two subs called\n";
}
 
Another alternative is to not use the button's -command for your handlers, but to use bindings.

Check out Tk::SignalSlot. The author explains it on this page:
Tk::SignalSlot is an alternative to bind, and can set up multiple handlers for each binding.

Code:
use Tk::SignalSlot;

my $button = $mw->Button (
   -label => 'Click Me!',
)->pack;

$button->connect ('<ButtonRelease-1>', \&handler_1);
$button->connect ('<ButtonRelease-1>', \&handler_2);
$button->connect ('<ButtonRelease-1>', \&handler_3);

 
Thanks twice.
Am I right to think that Perl/Tk is not that popular ,and there is no so much updated staff on web on it ?

Long live king Moshiach !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top