I don't think it has to do with buffering. AFAIK, Perl/Tk has a processing model in which you transfer the control to Tk via the MainLoop function, which in turn calls the callbacks provided by you when some events happen.

Now, when you're in the for loop (which is probably buried inside such a callback), Tk has no way to update the text box until you return from the callback and give control back to it. I'm no expert in Perl/Tk, but you can look for some "interim-update" functions that give control back to Tk temporarily, just to perform this kind of screen updates.

Does it make sense to you?

Update: perusing zentara's answer I noticed that I overlooked the fact that you're using sleeps, which you generally shouldn't for the reasons excellently explained above. OTOH, I hope you were using those sleeps just to explain your point clearly; if those sleeps actually mean "some heavy computation" try anyway to see if there's some interim-update function that you can put inside the computation inself, just to give some feedback ASAP.

Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

Don't fool yourself.

In reply to Re: Tk::Text and buffering, I think by polettix
in thread Tk::Text and buffering, I think by rvosa

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.