Hi Fellow Monks,

This is more of a Perl::Tk theory question. In normal procedural-flow programming one event leads on from the next, the output it processed onto the screen or console - its pretty standard. Tk is event driven and I'm coming to terms with its nature and how to program it. In doing so one develops a different way of having to think about structuring a program. If you click a button, X-event happens, screen changes, new widget developed, a small action taken, next button pushed and so on and so on ...

But my theory questions begins here ... what is the best way to program a long procedural like flow in Tk???


Do you:
1. Do a foreach loop and create and destroy a MainWindow for each directory. (Doesn't sound very gui pretty). In essence this is saying - to create a procedural like flow do you create and destroy the MainWindow to create the appearance of a procedural flow?
2. Can you get Tk to wait until one "fileevent" is done? Not sure how this would be achieved.
3. Do you string each event together via subroutines, creating a subroutine stack. That is, when one subroutine finishes it then calls the next tar, in effect creating a procedural-like flow from one subroutine to the next (replicating the procedural like flow of normal programming but giving the gui its fluid setp by step appearance?

For example I have a program that does a massive "tar" archiving. This requires calling the tar command using "fileevent" and then piping the output from all this to a text widget. "Fileevent" is used so the gui doesn't give the appearance of freezing. But my problem is I want to do consecutive tar's on different directories!!

In normal procedural-flow programming you'd do a "foreach" loop for each directory you want to tar. When one tar finishes it moves onto the next one. In Tk using "fileevent" this isn't possible because it doesn't suspend the background process, thereby keeping the gui "up-to-date". The event queuing is stuffed. Being event driven the "tar"'s get called rapidly in succession within the MainWindow and don't work.

How do I resolve this? I can give code but I think my explanation is enough for anyone who knows Tk.

Dean
The Funkster of Mirth
Programming these days takes more than a lone avenger with a compiler. - sam
RFC1149: A Standard for the Transmission of IP Datagrams on Avian Carriers

In reply to 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.