I see two possible ways:

Create your processing chain as follows:

  1. Produce list of all items to be processed
  2. Fire an event PROCESS_ONE_ITEM to yourself
  3. On PROCESS_ONE_ITEM do:
    1. Process that one item.
    2. Fire an event ITEM_PROCESSED to yourself
  4. On ITEM_PROCESSED do:
    1. update your status
    2. Fire an event PROCESS_ONE_ITEM to yourself, if there are more items in the queue

That way, you will process all items as long as there are items in the queue. The ugly part of this (and all event oriented processing) is, that all program flow logic gets moved to the events instead of the sequential ordering in the source code.

The other way is to simply spawn a "worker" Perl script that produces the "right" output by procedurally processing the list of items and interfacing to that single process from Tk via the one single Fileevent. This way has the advantage of having the program flow in a nice procedural way, and the disadvantage that you can't display nice progress unless you parse the output of your other program.


In reply to Re: Perl::Tk - Event sequencing question by Corion
in thread Perl::Tk - Event sequencing question by crabbdean

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.