Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > leaving mainloop

Reply
Thread Tools

leaving mainloop

 
 
Shea Martin
Guest
Posts: n/a
 
      11-10-2005
I am trying to add an alert pop-up message box to some perl scripts.

sub MsgBox
{
my $msg = shift;
if( length($msg) <= 0 )
{
$msg = "empty message?";
}
my $mw = Tk::MainWindow->new();
$mw->Label(-text => $msg)->pack;
$mw->Button(-text => 'ok', -command => sub{exit})->pack;
&Tk::MainLoop();
}


The problem is, I want to return to my perl script after the the 'ok'
button has been pressed. Obviously sub{exit} is the problem, but I
don't know what else to put? It won't let me put return or last in
there. I am sure that there is a simple way to do this, but I can't see
the forest for the trees.

~S
 
Reply With Quote
 
 
 
 
Shea Martin
Guest
Posts: n/a
 
      11-10-2005
Shea Martin wrote:
> I am trying to add an alert pop-up message box to some perl scripts.
>
> sub MsgBox
> {
> my $msg = shift;
> if( length($msg) <= 0 )
> {
> $msg = "empty message?";
> }
> my $mw = Tk::MainWindow->new();
> $mw->Label(-text => $msg)->pack;
> $mw->Button(-text => 'ok', -command => sub{exit})->pack;
> &Tk::MainLoop();
> }
>
>
> The problem is, I want to return to my perl script after the the 'ok'
> button has been pressed. Obviously sub{exit} is the problem, but I
> don't know what else to put? It won't let me put return or last in
> there. I am sure that there is a simple way to do this, but I can't see
> the forest for the trees.
>
> ~S


FOund my answer:

$mw->Button(-text => 'ok', -command => [$mw => 'destroy'])->pack;

~S
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
wxPython MainLoop exception handling problem Kreedz Python 2 09-12-2005 06:56 PM
detect tk mainloop John Hunter Python 0 01-26-2005 03:32 PM
Problem with tkinter mainloop k2riddim Python 2 11-30-2004 02:30 PM
Re: Tk mainloop() dan Python 0 07-20-2003 02:32 PM
Re: Tk mainloop() John Roth Python 0 07-20-2003 11:06 AM



Advertisments