Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

PERL TK logfile color coding error

by ghosh123 (Monk)
on Jul 17, 2012 at 14:01 UTC ( #982246=perlquestion: print w/ replies, xml ) Need Help??
ghosh123 has asked for the wisdom of the Perl Monks concerning the following question:

Hi
I am using a scrolled text box for displaying my log results. The text box has a default foreground color(i.e blue) and default background colour (i.e white). But depending on some pass and fail results I am changing that colour to green and red respectively using tagConfigure.
But due to presence of some continuous special characer (like * ) in a line , the rest of the colour coding is getting destroyed.

For example if two consecutive lines contain :

***********************************
***********************************
The colur display is getting corrupted, can you please tell me why this is happening.
Below is the snippet of my logfile code and the tagConfigure sub routine :

Thanks in advance, please help. Assume that the below syntax are correct in my code, this is just to give you an idea of my code and how I am using this.

my $logfiletextbox = $frame->Scrolled ('Text', -scrollbars => 'osoe', -background => 'white', -foreground => 'blue'); $logfiletextbox-tagConfigure($tag, -foreground => 'green')if $result = +~ /pass/; $logfiletextbox-tagConfigure($tag, -foreground => 'red')if $result =~ +/fail/;

Comment on PERL TK logfile color coding error
Download Code
Replies are listed 'Best First'.
Re: PERL TK logfile color coding error
by zentara (Archbishop) on Jul 17, 2012 at 15:44 UTC
    Can you please post a minimally functional script that shows the actual problem? You don't show what $tag is, and I don't want to write a script just to test your erroneous syntax. :-)

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: PERL TK logfile color coding error
by Khen1950fx (Canon) on Jul 18, 2012 at 10:28 UTC
    Maybe something like this?
    #!/usr/local/bin/perl use strict; use autodie; use warnings; use Tk; @ARGV = __FILE__ unless (@ARGV); my @data = <>; my ($name) = 'fail'; my $top = MainWindow->new(); $top->optionAdd( '*Scrollbar.width' => '6.5m' ); $top->Button( -text => 'Quit', -command => [ destroy => $top ] )->pack( -side => 'bottom', -fill => 'x', ); if ( $name eq 'pass' ) { my $lba = $top->ScrlListbox( -background => 'white', -foreground => 'green', -scrollbars => 'rse', -label => 'Text', )->pack(); $lba->insert( 'end', @data ); } else { my $lbb = $top->ScrlListbox( -background => 'black', -foreground => 'red', -scrollbars => 'rse', -label => 'Text', )->pack(); $lbb->insert( 'end', @data ); } MainLoop();

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://982246]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2015-07-28 09:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (254 votes), past polls