in reply to Perl Tk-How to return from 'MainLoop'

In Perl Tk the MainLoop is not so much something that is called, but it is the event handler loop that keeps it all going. As someone else pointed out, you can destroy the $mw ( Main window ) object and then continue. But as for a pure return leaving the GUI running? No. The event loop responds to all the GUI events and also permits you to put your own callback's into the queue to be handled by several different stages of the event processing loop. It also has a delay mechanism and a periodical event timer mechanism as well.

If what you want is to put little dialogs windows in various places and then continue after they are handled, then that is easy. Here is something adapted from some code I am working on right now:

#!/usr/bin/perl -w use strict; use warnings; use Tk; my $mw = MainWindow->new(); $mw->withdraw(); my $ftp_warn = $mw->messageBox( -title => 'Silly message', -message => "We are displaying a silly message, do you wish to conti +nue?", -type => 'YesNo', -icon => 'question', ); if ( $ftp_warn eq 'No' ) { exit; } else { my $msg2 = $mw->messageBox( -title => 'Really?', -message => "We displayed silly message and you wish to continue?" +, -type => 'OK', -icon => 'question', ); exit; }
That code will run.

Now if you were to replace the else clause with a call to a function, then you can execute other code. This is naturally quite trivial, because in a Tk application you will have some sort of user interface that appears in the MinWindow (the $mw that I hid with the $mw->withdraw method call) whioch will direct what is to be done.

Tk is a very useful GUI tool, there are a number of heavy Tk users here in the Monastery. You will find it explained in the docs or you could look at Mastering Perl/Tk" by Lidie and Walsh published by O'Reilly.

jdtoronto