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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl TK (multiple -command's on a single button)

Status
Not open for further replies.

clueo8

Programmer
Jun 13, 2005
47
US
What I would like to do is have a button close my window (prompt_window), but also call a function (user_continue):

Code:
my $btn = $main -> Button (-text => 'Click Me',
-command => sub {$prompt_window -> destroy},
-command => \&user_continue)
-> pack ();

It only executes the last -command. Any help would be appriciated!

Tim
 
move $prompt_window -> destroy into the sub that's called perhaps?

HTH
--Paul

cigless ...
 
my prompt window isnt a global window, but another window created in a sub and it does not recognize it.
 
What about:

Code:
sub destroy_n_continue {
    $prompt_window->destroy;
    \&user_continue;
}

my $btn = $main -> Button (-text => 'Click Me',
-command => \&destroy_n_continue)
-> pack ();

- Rieekan
 
I was able to get that to work as long as I moved my declaration to the top of my script file. I still would like to know for the future how to execute 2 commands in a -command, i know theres got to be a way!
 
Combining all the above, you could keep the sub anonymous, alright when it's still short.
Code:
my $btn = $main -> Button (-text => 'Click Me',
-command => sub { $prompt_window -> destroy; &user_continue;})
-> pack ();

________________________________________
Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top