i have successfully figured out how to append strings to a listbox from a variable, now the problem is formatting the text. i can change the font size, face, ect but i cannot figure out how to color the text green or red, is there a package i am missing?

Here is the code, and i just want the if statement to color green if true and red if false.
use File::Slurp; use Digest::MD5; use Wx; use Wx qw(:everything); use Wx::Event qw(EVT_DROP_FILES); use Wx::DND qw(FileDropTarget); ###################################################################### +######## my $app = Wx::SimpleApp->new; my $frame = Wx::Frame->new( undef, -1, 'test tool', [150,600], Wx::Size->new(700,400), wxDEFAULT_DIALOG_STYLE|wxSTAY_ON_TOP ); ###################################################################### +######### tool($frame); sub tool { my ($self) = @_; $frame->DragAcceptFiles(1); EVT_DROP_FILES( $frame, \&ondrop ); sub ondrop { my ($self, $this) = @_; $lb->Clear(); Wx::DropFilesEvent::GetFiles($this); our $dropfile = $this->GetFiles(); \&file($dropfile); } my $noteBook = Wx::Notebook->new($frame, -1, wxDefaultPosition, wx +DefaultSize); my $window1 = Wx::Panel->new($noteBook, wxID_ANY); my $window2 = Wx::Panel->new($noteBook, wxID_ANY); my $window3 = Wx::Panel->new($noteBook, wxID_ANY); $noteBook->AddPage($window1, "First", 1, 0); $noteBook->AddPage($window2, "Second", 0, 1); $noteBook->AddPage($window3, "Third", 0, 2); our $lb = $window1->{my_listbox} = Wx::ListBox->new($window1, wxID_ANY, [350 , 10] +, Wx::Size-> +new(300,330 )); sub file { my $dirname = "extracted/"; my @md5s = read_file("md5"); my $md5s = join( '', @md5s ); my $filesize = ''; open( my $buf1, '<', "extracted/sdk_version" ) or die "cannot open sdk +_version: $!"; seek( $buf1, 0x00, 0 ); read( $buf1, my $sdk, 0x03 ); foreach my $file (<$dirname/*>) { next if -d $file; open( my $FILE, $file ); binmode($FILE); $filesize = -s $FILE; $file =~ s{.*/}{}; $md5 = Digest::MD5->new->addfile($FILE)->hexdigest; if ( $md5s =~ $md5 ) { $lb->SetFont( Wx::Font->new( 7, wxDEFAULT, wxNORMAL, wxBOLD, # would like to set color somewhere in these properties 0, "Comic Sans MS" ) ); $lb->Append(" Match! | $sdk | $file | $filesize"); } else { $lb->SetFont( Wx::Font->new( 7, wxDEFAULT, wxNORMAL, wxBOLD, # would like to set color somewhere in these properties 0, "Comic Sans MS" ) ); $lb->Append(" Warning! | $sdk | $file | $filesize"); } } } } $frame->Show(1); $app->SetTopWindow($frame); $app->MainLoop;


in the code above, it opens a window and when you drop a file on it, it runs it thru the "sub file". this sub is setup to open a directory and get md5 of everyfile in that directory, then open an exsisting md5 file and store it in array, then join the array into "$md5s". after that it also gets the filename ($file =~ s{.*/}{};) and get filesize ($filesize = -s $FILE;). after that, it compares the output of the "$md5" from each file in the directory against the stored "$md5s".
if the $md5 from the files matches the md5s thats stored in $md5s, it will return true and append "" Match! | $sdk | $file | $filesize" to the listbox. if it returns false, it will append "" Warning! | $sdk | $file | $filesize". This is where i want to make the text red or green. if it returns true, i would like the text to be green, if it returns false i would like it to be red.

In reply to How do i color font in a listbox? (Solved!!!) by james28909

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.