I agree with pc88mixer. You need to run the snmp code in a separate thread, or thru some IPC module( a fork). The reason do_one_event won't work, is that the snmp stuff hogs the execution pointer and won't let Tk get any control. There are alot of examples here and on groups.google for "Tk threads" and "Tk::IPC".

Actually it look very easy to convert to threads.... just make your StrtScan sub a thread, create it before any Tk code is called, and remove any Tk code from it. Set up some shared variables, and a Tk::timer to read them from the thread, for inter-thread communication.

I'm not familiar with Net::SNMP, but there MAY be a mechanism to get your script to work, like setting a timeout and running do_one_loop at each timeout, or possible Net::SNMP has a hook to run external code, in which you can do_one_loop.


I'm not really a human, but I play one on earth. Cogito ergo sum a bum

In reply to Re: perl/tk script freezes by zentara
in thread perl/tk script freezes by Anonymous Monk

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.