Hello,

I am writing an event driven system wherein as one top level window is
closed, another pops up. I provide an Exit button on each window that
has it's own routine for cleaning up and exiting. If the user instead
clicks the upper right window cross hair to close the window, I still
want to go to the said cleaning up routine. The call below does not
work. $top of course is a Toplevel reference.

$top->protocol( 'WM_DELETE_WINDOW', \&my_clean_up_routine( $top, $another_parameter);

The call is fashioned after this example from http://www.lns.cornell.edu/~pvhp/ptk/ptkFAQ.html

$window->protocol('WM_DELETE_WINDOW',\&your_exit_handler);

Perhaps the problem is that no parameters are allowed. I am guessing
that because the code below works in that if using it, the said cross
hairs will not close the window out, which breaks tradition.

$window->protocol( 'WM_DELETE_WINDOW', \&Tk::NoOp);

Any ideas?


In reply to Perl/Tk window->protocol question by mnooning

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.