It would be complicated (if not impractical)to write Perl code that allowed all the possibilities required when for example different columns were to be sorted.However, it is relatively easy to write the Perl ‘sort’ string that defines the sort. In this case it isforeach $jrow (sort $ref_spv->{$a}->{Symbol} <=> $ref_spv->{$b}->{Symbol} || $ref_spv->{$b}->{Sel120} <=> $ref_spv->{$a}->{Sel120} || $ref_spv->{$a}->{Sel119} cmp $ref_spv->{$b}->{Sel119} } keys %$ref_spv) { push(@$ref_new_order, $jrow); }
The hash is then sorted by the Perl$ref_spv->{$a}->{Symbol} <=> $ref_spv->{$b}->{Symbol} || $ref_spv->{$b}->{Sel120} <=> $ref_spv->{$a}->{Sel120} || $ref_spv->{$a}->{Sel119} cmp $ref_spv->{$b}->{Sel119}
where $sort_str is the Perl ‘sort’ string. Tablematrix cell characteristics. The Tablematrix is a highly configurable widget that is a two dimensional table similar to a table in Excel.Each cell in the table can have its own characteristics similar to individual widgets such as Entry boxes. Therefore the background and foreground colours, the font and other things can be defined.The cell definition is carried using a tag. When a tag is applied to a cell, all the characteristics set by other tags are overwritten. Using a tag is a 2 stage process where the tag is defined and the defined tag is applied to one or more cells.The tag is defined with Perl typically likeforeach $jrow (sort { eval($sort_str); } keys %$ref_spv) { (@$ref_new_order
In this case The name of the tag is stored in $tag_name This tag defines a condition where the cell will be disabled and the background colour is black.The tag is applied with Perl typically like$t->tagConfigure($tag_name, -state => 'disabled', -bg => 'black');
The tag defined as $tag_name is applied to the cell with the ‘index stored in $cell_index. The cell index has the form row,column. Therefore an index of 2,3 refer to the cell row of 2 and column of 3. I found that I wanted to: 1. set rows to a specific thing – for example background colour which differ from row to row; 2. set some columns to have a specific font; 3. override the general row and columns settings for individual cells. I was working with tables that had around 20,000 cells. Therefore it would have been impractical to write individual tag definition and application Perl lines.However, it was possible to build up and store the definition of the tags for all these cells and then apply them.The stored definition, for example -state => 'disabled', -bg => 'black' was defined using eval as shown next.$t->tagCell($tag_name, $cell_index);
where $tag_string was set to -state => 'disabled', -bg => 'black' The tag was applied in exactly the same way.$t->tagConfigure($tag_name, eval($tag_string));
In reply to Uses of eval (sorting and tablematrix tags) by merrymonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |