What about just using a file event callback? Something like:
$widget->fileevent($fh, 'readable' => sub { ...call-back code... });
In the call-back code you can directly interact with other widgets - e.g. change the text of a widget, etc.

Also, since you are accessing the serial port as /dev/ttyS0, you should just be able to open and read/write to it directly just like any other file object:

open(S, '+<', '/dev/ttyS0'); read(S, $buf, 1024, length($buf)); print S "etc.\n";
The Device::SerialPort module is still useful for configuring the port, but it's not needed to read/write to it. One additional configuration you might want to use it to put the port into 'raw' mode instead of line-buffered mode. To be honest, I'm not really sure how it's done with Device::SerialPort -- I've always used the old-school system("stty -F /dev/ttyS0 raw"). :-)

Finally, I haven't tried it, but judging from this example code, file event call-backs should work even in a Win32 environment.

Update: Have a look at this page for an example of the fileevent call-back (under 'Executing Nonblocking System Commands') The code reads from a pipe, but the principle is the same with a serial port.


In reply to Re: Posting thread data in a Perl/Tk window by pc88mxer
in thread Posting thread data in a Perl/Tk window by Bruce32903

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.