G'day simonz,

Welcome to the monastery.

That's actually a rather vague question; however, the mechanism you're probably looking for is the callback (see Tk::callbacks).

A Tk application is event-driven. You don't write code that waits for some event to occur (or complete), you associate a callback with the event which is called when that event occurs (or completes). Here's some examples:

If the processing involved with a callback takes an inordinate amount of time to complete, then you may need a separate process so that the Tk process doesn't block. That could involve threads or forking a child process (see perlipc). Here's a fairly straightforward way of forking a long running process, using open and Tk::fileevent, that won't block while waiting for the child process to return output:

open my $pipe, '-|', 'long_running_process.pl'; $mw->fileevent($pipe, 'readable', $callback);

As I said at the start, your question is rather vague. The information I've provided here should be sufficient for dealing with the usual culprits. If you're having difficulty with a particular problem that I haven't addressed, post specific information and we can look at it. If you do need to post a follow-up question, please follow the guidelines in "How do I post a question effectively?": a better question gets better answers.

-- Ken


In reply to Re: perl tk mainwindow hangs by kcott
in thread perl tk mainwindow hangs by simonz

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.