http://www.perlmonks.org?node_id=965348


in reply to Re: ItemStyle causing high memory consumption
in thread ItemStyle causing high memory consumption

Hello zentara, Thanks for replying. A more elaborated exapmle could be like this say in D1.pm :

my $style1 = $tree-> ItemStyle ('text', -anchor => 'w', -font => 'Time +s 12',-justify => 'right'); $tree->ItemConfigure($self->treeEntryPath, $self->columnNo(), -text => + $result , -style => $style1 )

Similarly for $style2 in D1.pm

my $style2 = $tree->ItemStyle ('text', -anchor => 'e', -font => 'Couri +er 16' -foreground => 'red', -justify => 'left'); $tree->ItemConfigure($self->treeEntryPath, $self->columnNo(), -text => + $name , -style => $style2 )

Posting a running example would be difficult since it is part of big code base. All I need is to program the logic so that in place of $style1 or $style2 , I will call a base class function which will create the itemStyle there once for each parameter set and return it to the derived class. Say from D1.pm, I will call it like :

$style1 = $baseObject->getItemStyle($tree, 'text',-anchor =>'nw', -fg +=> 'red');

I need help in programming the logic in the getItemStyle() of base class, so that it can create the ItemStyle widget from the passed parameter and store them in a hash. So that for the same parameter combination later I don't need to create it again. From the hash key-value pair I will get the stored ItemStyle created earlier.