You can't have multiple colored lines (different colored lines) in a listbox (afaik), you should use the text widget and configure some tags for different colors. Below is a replacement for everything in your script starting from the text box comment (now we use text widget). This doesn't use fileevent because you are just reading from the log file itself rather than a continuous process:

##### # # Main Text Box # ##### my $text = $mw->Scrolled('Text', -relief => 'sunken', -width => 100, -height => 30, -background => 'white'); $text->pack(-side => 'left', -fill => 'both', -expand => 'yes'); $text->tagConfigure('CRITICAL', -foreground => 'red'); $text->tagConfigure('MAJOR', -foreground => 'pink'); # loop and subroutine to enter text from logfile into listbox #$mw->fileevent(LOG, 'readable', [\&insert_lines]); insert_lines(); MainLoop(); ##### # # Subroutines # ##### sub insert_lines { while(<LOG>){ if(/(CRITICAL|MAJOR)/){ $text->insert('end',$_,$1); }else{ $text->insert('end',$_); } } }

hope it helps some.


In reply to Re: TK Problem (me again) by danger
in thread TK Problem (me again) by locked_user mr_leisure

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.