The issue is that within the call to check_for_status(); is a webpage scrape; there is no way to have the webpage "push" the status changes to me; I have to determine that myself. For that reason a while (1) loop seems necessary.

Well I certainly hope that whoever is operating the webpage doesn't mind you polling the page that often, and that you're not voilating any TOS. You should definitely add a delay in there so that you're not hitting the webserver constantly.

If this is a Tk GUI then you will need the MainLoop;, and everything needs to happen in there, and kcott's comment that you're on the wrong track by writing your own loop is correct. This means you need to use Tk's functionalities to achieve your "loop", which is usually done by setting a timer to go off in the future, which will then run a callback inside of the main loop, and the callback then starts a new timer. Though I am far from a Tk expert, Tk::after as suggested by kcott seems to be a way to achieve this (Update: tybalt89 and kcott have since posted examples). Either that, or spawn a separate thread/process, though then you've got the complication of two processes needing to be managed and needing to communicate.

Of course, it's a different story if the only thing your code is doing is sending notifications, then most modern window managers have built-in notifications that you can use. For example, on Ubuntu, there's notify-send, which exits immediately and therefore wouldn't block your script (see Calling External Commands More Safely).


In reply to Re^3: How to display Tk window without waiting for user input by haukex
in thread How to display Tk window without waiting for user input by Special_K

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.