The short answer is that it doesn't wait. The longer reason involves how your function intereacts with the event loop. Your &show_list function sets up and displays the window, probably by making a new TopLevel (we'll call this new TopLevel $dialog). Then, the function returns -- it has no way of knowing that it needs to wait for input; indeed, there is no way to make it stick around inside the subroutine waiting for input. All of the input has to be handled via the event loop. So the only way to do this is to split things up.

As the poster above said, you need to make $dialog modal. The only time when you're guaranteed to know the value of the variable is when you close $dialog -- so attach all of your computations, etc, to the callback on the "OK" button on $dialog.

Hope this helps -- if not, ask and I'll post an example of what I mean.


In reply to Re: pTk popup not returning value and not locking calling window by Chmrr
in thread pTk popup not returning value and not locking calling window by el-moe

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.