The second is standalone because it's general purpose and I didn't want to rewrite it every place I want to use it.

Points for reuse, but I think your approach has lots of unintended consequences that will require the parent and child to be more complex as a result. You can have the child exit with various codes that your parent can interpret and act accordingly, and that's not really that complex, but will the child be providing other user-supplied information back to the parent? Will the child be around for long time? For example, under your current strategy, your parent will not be able to receive events until the child is done (exits), unless you're using something like fileevent.

My suggestion would be to create a module out of your reused second window, and treat the second window as a dialog box. for your parent. Your code will be much simpler as a result. Update: (see my followup for examples)

is there a way to catch that 'x' signal?

Yes. What you're looking for is something like this:

use Tk; my $mw = MainWindow->new; $mw->protocol(WM_DELETE_WINDOW => sub { print "Exiting appliction!\n"; exit; }); MainLoop;
Rob

In reply to Re: Handling child process and close window exits in Perl/Tk by rcseege
in thread Handling child process and close window exits in Perl/Tk by meliason

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.