Hello jmClifford,

the MainLoop as I understand it, takes the control of all events in your program, in a higher position, as Tk programs are event driven so I suppose ( WRONG supposition, see haj's reply)(and I'm bit surprised by your while 1 loop working ok) that when the MainLoop schedules events your while 1 loop falls into the category of idle events (to be confirmed) after windows, files and timers ones (in this order).

Infact when you realize that you are already inside an infinite loop seems weird to put in another one inside the main. General practice is to use Tk::after's after and repeat utilities.

About my $text_label ..I must admit I do not fully understand your sentence, but, for me you are declaring a variable and when you pack the MainLoop draws it on the screen, then you reuse the same variable to hold something else and you draw... it works but for me is misleading and bug prone. Just name 3 variables:

my $text_label_GREEN = $left_frame->Label->pack(... my $text_label_RED = $left_frame->Label->pack(... ..

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

In reply to Re: Basic questions of Tk programming -- updated by Discipulus
in thread Basic questions of Tk programming by jmClifford

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.