In the Tk program I've been working on, I have a few different subroutines bound to different keyboard events. I use $widget->Busy() inside of these routines to turn the cursor into an hour glass, as these events may occasionally take a couple of seconds to run without any noticeable changes on the screen.

So my issue is I noticed that when I typed several different event bound key sequences in rapid succession, the events occurred in exactly the reverse order, every time. Though they worked perfectly fine when I keyed in the bound sequences at a slower pace.

What seems to be happening is that when the code gets to the $widget->Busy statement, it pauses until the event queue is clear. So if I type fast enough to generate these events quickly enough, each event's code pauses itself once it gets to the Busy statement until the event after it has completed. capiche? See, the last event typed is the first event to reach it's Busy statement without any other events after it already in the queue, so it actually completes first even though it was generated last.

Now I couldn't actually make this happen on my own pc running activestate perl, I assume because the events were received and executed faster than I could type them. But on a Unix server across the internets I kept having that problem with my code and I wasn't even typing all that fast.

Specifically I was working on some undo/redo routines. And if I type control-z (undo) followed rapidly by control-y (redo) or vice versa they would execute in backwards order. Probably nobody will ever type Undo and Redo as deliberately quickly as I did, and if they do they probably will hardly notice, but still this seems like a big problem to me.

Is anybody else familiar with this situation? I am aware that the cursor can be changed to 'watch' without using Busy. I think that's probably what I will do. But I thought this situation was amusing. I thought it seemed quite intuitive to use the Busy method in my code, but in reality, and due to a feature of Busy that I did not see documented in the documentation for Busy, it turned out to be all wrong.

Unless I'm misunderstanding something and someone else has some insight?


In reply to Tk::Widget's Busy method can result in LIFO event execution order? by gleepglop

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.