0

I'm trying to alert the user that some data has been changed and needs to be saved. The data is displayed in Perl's Tk::HList box. I was hoping I could do:

if ($new_item) {
  $HList->add($stock_no,-background=>"red");
}

or even:

if ($new_item) {
  $HList->itemCreate($stock_no,0,-text=>$stock_no,-background=>"red");
}

but both throw

Tk::Error: Bad option `-background' 

I've seen the idea to use ItemStyle but there's no clear answer if that works or not or if it's the best (and only) solution. Is there another way to highlight certain rows to alert the user?

charlesbridge
  • 1,172
  • 10
  • 21

1 Answers1

0

It looks like it is the best way to change the background:

use Tk::ItemStyle; 

my $alert = $mw->ItemStyle('text',-background=>"red");

$HList->itemCreate($stock_no,0,-style=>$alert);

I have to include that style to each item I add, there doesn't seem to be a way to do the whole row at once.

charlesbridge
  • 1,172
  • 10
  • 21